{"id":109476,"date":"2020-02-21T15:46:34","date_gmt":"2020-02-21T15:46:34","guid":{"rendered":"http:\/\/gamefromscratch.com\/post.aspx?id=1bdfea63-bc98-4512-abab-7d27e3d47807"},"modified":"2020-02-21T15:46:34","modified_gmt":"2020-02-21T15:46:34","slug":"global-illumination-in-godot","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2020\/02\/21\/global-illumination-in-godot\/","title":{"rendered":"Global Illumination In Godot"},"content":{"rendered":"<p>Global Illumination describes several algorithms used to calculate non-direct lights in game engines.&nbsp; In Godot, it\u2019s implemented using the GIProbe node, which can calculate emissive lights and secondary reflections, giving you more accurate lighting in your scene at the cost of performance.&nbsp; In this tutorial we will go step by step through the process of setting up a GIProbe.&nbsp; You can learn more in the <a href=\"https:\/\/youtu.be\/W19zgasQK-c\">video<\/a> embedded below.<\/p>\n<p>The first step for setting up global illumination is to go through the scene, select each model that will participate in the calculations and select Use in Baked Lighting in the Geometry Instance section.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3480.png\"><img loading=\"lazy\" decoding=\"async\" width=\"432\" height=\"178\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot.png\" border=\"0\"><\/a><\/p>\n<p>Once you have your models set to participate, it\u2019s time to create a GIProbe node.&nbsp; Add a new Node to the Scene (doesn\u2019t matter who it is parented to) of type GIProbe.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3481.png\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"189\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-1.png\" border=\"0\"><\/a><\/p>\n<p>Now size the GIProbe box using the red\/pink control handles, so that it envelops your scene.&nbsp; You can have multiple GIProbes per scene and having them overlap serves no purpose.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3482.png\"><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"426\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-2.png\" border=\"0\"><\/a><\/p>\n<p>Now with at least one light source in the scene, with GIProbe selected, click Bake GI Probe in the menubar.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3483.png\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"66\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-3.png\" border=\"0\"><\/a><\/p>\n<p>This will calculate the indirect lights in your scene.&nbsp; You can also have a GIProbe calculate the effects of emissive lights in your scene.&nbsp; Emissive lights are lights that are projected from textures.&nbsp; In a SpatialMaterial you can turn emissive on in the Emission tab by selecting Enabled.&nbsp; Emission is the color of the light emitted, while energy is the strength of the energy emitted.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3484.png\"><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"208\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-4.png\" border=\"0\"><\/a><\/p>\n<p>Emissive lights will only be shown after being baked by a GIProbe.&nbsp; Emissive lights cannot move without baking the scene again.&nbsp; You can cause a GIProbe to bake lights in code using the following code:<\/p>\n<pre>\t<span>get_node<\/span><span>(<\/span><span>\"..\/GIProbe\"<\/span><span>).<\/span><span>bake<\/span><span>()<\/span> <\/pre>\n<p>This is an expensive operation and should not be performed lightly.<\/p>\n<p>There are a couple of ways to control the quality of the lighting generated by a GIProbe.&nbsp; The first is by setting the Subdiv property in the GIProbe.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3485.png\"><img loading=\"lazy\" decoding=\"async\" width=\"441\" height=\"359\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-5.png\" border=\"0\"><\/a><\/p>\n<p>The higher the resolution, the better the results but more expensive the calculations.&nbsp; You can also change the quality of lighting in Project Settings by enabling High Quality in Voxel Cone Tracing.&nbsp; <\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3486.png\"><img loading=\"lazy\" decoding=\"async\" width=\"754\" height=\"607\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-6.png\" border=\"0\"><\/a><\/p>\n<p>Once again, this is a trade off between quality and performance.&nbsp; Finally I should point out that GIProbe only works with the OpenGL ES3 renderer, not in ES2.&nbsp; On ES2 you are instead stuck with traditional Light Baking, which takes less processing power, but produces inferior and less dynamic results.<\/p>\n<p>Another thing to be aware of is dealing with the GIProbe inside the Godot Editor.&nbsp; The GIProbe, as shown above, is a giant green lattice, which can make viewing your scene somewhat difficulty.&nbsp; You may be tempted to hide the GIProbe like so:<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3487.png\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"76\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-7.png\" border=\"0\"><\/a><\/p>\n<p>Unfortunately this turns the GI off completely!&nbsp; If instead you want to hide the GIProbe in the viewport, you turn it off in the viewport menu.&nbsp; In the viewport, select View-&gt;Gizmoes-&gt;GIProbe.<\/p>\n<p><a href=\"https:\/\/www.gamefromscratch.com\/image.axd?picture=image_3488.png\"><img loading=\"lazy\" decoding=\"async\" width=\"478\" height=\"410\" title=\"image\" alt=\"image\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/global-illumination-in-godot-8.png\" border=\"0\"><\/a><\/p>\n<p>This value is a toggle and controls ALL GIProbes in the scene.<\/p>\n<p>You can learn more about Global Illumination and GI Probes in the video below.<\/p>\n<p align=\"center\">[embedded content]<\/p>\n<p class=\"under\"> <span class=\"categories\"><a href=\"https:\/\/www.gamefromscratch.com\/category\/Programming.aspx\">Programming<\/a> <a href=\"https:\/\/www.gamefromscratch.com\/category\/Design.aspx\">Design<\/a><\/span> <span class=\"tags\"><a href=\"https:\/\/www.gamefromscratch.com\/?tag=\/Godot\" rel=\"tag\">Godot<\/a> <a href=\"https:\/\/www.gamefromscratch.com\/?tag=\/Tutorial\" rel=\"tag\">Tutorial<\/a><\/span> <\/p>\n<hr>\n<p> &lt;!&#8211;<\/p>\n<p>&#8211;&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Global Illumination describes several algorithms used to calculate non-direct lights in game engines.&nbsp; In Godot, it\u2019s implemented using the GIProbe node, which can calculate emissive lights and secondary reflections, giving you more accurate lighting in your scene at the cost of performance.&nbsp; In this tutorial we will go step by step through the process of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":109477,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,64],"tags":[177,73],"class_list":["post-109476","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-game-development","category-programming","tag-design","tag-programming"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/109476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=109476"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/109476\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/109477"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=109476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=109476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=109476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}