using_voxel_gi.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. .. _doc_using_voxel_gi:
  2. Using Voxel global illumination
  3. ===============================
  4. VoxelGI is a form of fully real-time global illumination, intended to be used
  5. for small/medium-scale 3D scenes. VoxelGI is fairly demanding on the GPU, so
  6. it's best used when targeting dedicated graphics cards.
  7. .. important::
  8. VoxelGI is only supported when using the Forward+ renderer, not the Mobile or
  9. Compatibility renderers.
  10. .. seealso::
  11. Not sure if VoxelGI is suited to your needs?
  12. See :ref:`doc_introduction_to_global_illumination_comparison`
  13. for a comparison of GI techniques available in Godot 4.
  14. Visual comparison
  15. -----------------
  16. .. figure:: img/gi_none.webp
  17. :alt: VoxelGI disabled.
  18. VoxelGI disabled.
  19. .. figure:: img/gi_voxel_gi.webp
  20. :alt: VoxelGI enabled.
  21. VoxelGI enabled.
  22. Setting up VoxelGI
  23. ------------------
  24. 1. Make sure your static level geometry is imported with the Light Baking option
  25. set to **Static** or **Static Lightmaps** in the Import dock.
  26. For manually added MeshInstance3D nodes, make sure the **Global Illumination > Mode**
  27. property is set to **Static** in the inspector.
  28. 2. Create a VoxelGI node in the Scene tree dock.
  29. 3. Move the VoxelGI node to the center of the area you want it to cover by
  30. dragging the manipulation gizmo in the 3D viewport. Then adjust the VoxelGI's
  31. extents by dragging the red points in the 3D viewport (or enter values in the
  32. inspector). Make sure the VoxelGI's extents aren't unnecessarily large, or
  33. quality will suffer.
  34. 4. Select the VoxelGI node and click **Bake** at the top of the 3D editor viewport.
  35. This will take at least a few seconds to complete (depending on the number of VoxelGI
  36. subdivisions and scene complexity).
  37. If at least one mesh contained within the VoxelGI's extents has its global
  38. illumination mode set to **Static**, you should see indirect lighting appear
  39. within the scene.
  40. .. note::
  41. To avoid bloating text-based scene files with large amounts of binary data,
  42. make sure the VoxelGIData resource is *always* saved to an external binary file.
  43. This file must be saved with a ``.res`` (binary resource) extension instead of
  44. ``.tres`` (text-based resource).
  45. Using an external binary resource for VoxelGIData will keep your text-based
  46. scene small while ensuring it loads and saves quickly.
  47. VoxelGI node properties
  48. -----------------------
  49. The following properties can be adjusted in the VoxelGI node inspector before
  50. baking:
  51. - **Subdiv:** Higher values result in more precise indirect lighting, at the cost
  52. of lower performance, longer bake times and increased storage requirements.
  53. - **Extents:** Represents the size of the box in which indirect lighting should
  54. be baked. Extents are centered around the VoxelGI node's origin.
  55. The following properties can be adjusted in the VoxelGIData *resource* that is
  56. contained within a VoxelGI node after it has been baked:
  57. - **Dynamic Range:** The maximum brightness that can be represented in indirect lighting.
  58. Higher values make it possible to represent brighter indirect light,
  59. at the cost of lower precision (which can result in visible banding).
  60. If in doubt, leave this unchanged.
  61. - **Energy:** The indirect lighting's overall energy. This also effects the energy
  62. of direct lighting emitted by meshes with emissive materials.
  63. - **Bias:** Optional bias added to lookups into the voxel buffer at runtime.
  64. This helps avoid self-occlusion artifacts.
  65. - **Normal Bias:** Similar to **Bias**, but offsets the lookup into the voxel buffer
  66. by the surface normal. This also helps avoid self-occlusion artifacts. Higher
  67. values reduce self-reflections visible in non-rough materials, at the cost of
  68. more visible light leaking and flatter-looking indirect lighting. To
  69. prioritize hiding self-reflections over lighting quality, set **Bias** to
  70. ``0.0`` and **Normal Bias** to a value between ``1.0`` and ``2.0``.
  71. - **Propagation:** The energy factor to use for bounced indirect lighting.
  72. Higher values will result in brighter, more diffuse lighting
  73. (which may end up looking too flat). When **Use Two Bounces** is enabled,
  74. you may want to decrease **Propagation** to compensate for the overall brighter
  75. indirect lighting.
  76. - **Use Two Bounces:** If enabled, lighting will bounce twice instead of just once.
  77. This results in more realistic-looking indirect lighting, and makes indirect lighting
  78. visible in reflections as well. Enabling this generally has no noticeable performance cost.
  79. - **Interior:** If enabled, environment sky lighting will not be taken into account by VoxelGI.
  80. This should be enabled in indoor scenes to avoid light leaking from the environment.
  81. VoxelGI interaction with lights and objects
  82. -------------------------------------------
  83. To ensure correct visuals when using VoxelGI, you must configure your meshes
  84. and lights' global illumination properties according to their *purpose* in the
  85. scene (static or dynamic).
  86. There are 3 global illumination modes available for meshes:
  87. - **Disabled:** The mesh won't be taken into account for VoxelGI baking.
  88. The mesh will *receive* indirect lighting from the scene, but it will not
  89. *contribute* indirect lighting to the scene.
  90. - **Static (default):** The mesh will be taken into account for VoxelGI baking. The mesh will
  91. both receive *and* contribute indirect lighting to the scene. If the mesh
  92. is changed in any way after baking, the VoxelGI node must be baked again.
  93. Otherwise, indirect lighting will look incorrect.
  94. - **Dynamic:** The mesh won't be taken into account for VoxelGI baking, but it will
  95. still receive *and* contribute indirect lighting to the scene in real-time.
  96. This option is much slower compared to **Static**. Only use the **Dynamic**
  97. global illumination mode on large meshes that will change significantly during gameplay.
  98. Additionally, there are 3 bake modes available for lights
  99. (DirectionalLight3D, OmniLight3D and SpotLight3D):
  100. - **Disabled:** The light won't be taken into account for VoxelGI baking.
  101. The light won't contribute indirect lighting to the scene.
  102. - **Static:** The light will be taken into account for VoxelGI baking.
  103. The light will contribute indirect lighting to the scene. If the light
  104. is changed in any way after baking, the VoxelGI node must be baked again or
  105. indirect lighting will look incorrect. If in doubt, use this mode for level lighting.
  106. - **Dynamic (default):** The light won't be taken into account for VoxelGI baking,
  107. but it will still contribute indirect lighting to the scene in real-time.
  108. This option is slower compared to **Static**. Only use the **Dynamic** global
  109. illumination mode on lights that will change significantly during gameplay.
  110. .. note::
  111. The amount of indirect energy emitted by a light depends on its color,
  112. energy *and* indirect energy properties. To make a specific light emit more
  113. or less indirect energy without affecting the amount of direct light emitted
  114. by the light, adjust the **Indirect Energy** property in the Light3D inspector.
  115. .. seealso::
  116. See :ref:`doc_introduction_to_global_illumination_gi_mode_recommendations`
  117. for general usage recommendations.
  118. Adjusting VoxelGI performance and quality
  119. -----------------------------------------
  120. Since VoxelGI is relatively demanding, it will perform best on systems with recent
  121. dedicated GPUs. On older dedicated GPUs and integrated graphics,
  122. tweaking the settings is necessary to achieve reasonable performance.
  123. In the Project Settings' **Rendering > Global Illumination** section,
  124. VoxelGI quality can also be adjusted in two ways:
  125. - **Voxel Gi > Quality:** If set to **Low**
  126. instead of **High**, voxel cone tracing will only use 4 taps instead of 6.
  127. This speeds up rendering at the cost of less pronounced ambient occlusion.
  128. - **Gi > Use Half Resolution:** If enabled, both VoxelGI and SDFGI will have
  129. their GI buffer rendering at halved resolution. For instance, when rendering
  130. in 3840×2160, the GI buffer will be computed at a 1920×1080 resolution.
  131. Enabling this option saves a lot of GPU time, but it can introduce visible
  132. aliasing around thin details.
  133. Note that the **Advanced** toggle must be enabled in the project settings dialog
  134. for the above settings to be visible.
  135. Additionally, VoxelGI can be disabled entirely by hiding the VoxelGI node.
  136. This can be used for comparison purposes or to improve performance on low-end systems.
  137. Reducing VoxelGI light leaks and artifacts
  138. ------------------------------------------
  139. After baking VoxelGI, you may notice indirect light is leaking at some spots
  140. in your level geometry. This can be remedied in several ways:
  141. - For both light leaking and artifacts, try moving or rotating the VoxelGI node
  142. then bake it again.
  143. - To combat light leaking in general, ensure your level geometry is fully sealed.
  144. This is best done in the 3D modeling software used to design the level,
  145. but primitive MeshInstance3D nodes with their global illumination mode set to
  146. **Static** can also be used.
  147. - To combat light leaking with thin geometry, it's recommended to make the geometry
  148. in question thicker. If this is not possible, then add a primitive MeshInstance3D
  149. node with its global illumination mode set to **Static**. Bake VoxelGI again,
  150. then hide the primitive MeshInstance3D node (it will still be taken into account by VoxelGI).
  151. For optimal results, the MeshInstance3D should have a material whose color
  152. matches the original thin geometry.
  153. - To combat artifacts that can appear on reflective surfaces, try increasing
  154. **Bias** and/or **Normal Bias** in the VoxelGIData resource as described above.
  155. Do not increase these values too high, or light leaking will become more pronounced.
  156. If you notice VoxelGI nodes popping in and out of existence as the camera moves,
  157. this is most likely because the engine is rendering too many VoxelGI instances
  158. at once. Godot is limited to rendering 8 VoxelGI nodes at once, which means up
  159. to 8 instances can be in the camera view before some of them will start
  160. flickering.
  161. Additionally, for performance reasons, Godot can only blend between 2 VoxelGI
  162. nodes at a given pixel on the screen. If you have more than 2 VoxelGI nodes
  163. overlapping, global illumination may appear to flicker as the camera moves or
  164. rotates.