environment_and_post_processing.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. .. _doc_environment_and_post_processing:
  2. Environment and post-processing
  3. ===============================
  4. Godot 3 provides a redesigned Environment resource, as well as a new
  5. post-processing system with many available effects right out of the box.
  6. Environment
  7. -----------
  8. The Environment resource stores all the information required for controlling
  9. rendering environment. This includes sky, ambient lighting, tone mapping,
  10. effects, and adjustments. By itself it does nothing, but it becomes enabled once
  11. used in one of the following locations in order of priority:
  12. Camera node
  13. ^^^^^^^^^^^
  14. An Environment can be set to a camera. It will have priority over any other setting.
  15. .. image:: img/environment_camera.png
  16. This is mostly useful when wanting to override an existing environment,
  17. but in general it's a better idea to use the option below.
  18. WorldEnvironment node
  19. ^^^^^^^^^^^^^^^^^^^^^
  20. The WorldEnvironment node can be added to any scene, but only one can exist per
  21. active scene tree. Adding more than one will result in a warning.
  22. .. image:: img/environment_world.png
  23. Any Environment added has higher priority than the default Environment
  24. (explained below). This means it can be overridden on a per-scene basis,
  25. which makes it quite useful.
  26. Default environment
  27. ^^^^^^^^^^^^^^^^^^^
  28. A default environment can be set, which acts as a fallback when no Environment
  29. was set to a Camera or WorldEnvironment.
  30. Just head to Project Settings -> Rendering -> Environment:
  31. .. image:: img/environment_default.png
  32. New projects created from the Project Manager come with a default environment
  33. (``default_env.tres``). If one needs to be created, save it to disk before
  34. referencing it here.
  35. Environment options
  36. -------------------
  37. Following is a detailed description of all environment options and how they
  38. are intended to be used.
  39. Background
  40. ^^^^^^^^^^
  41. The Background section contains settings on how to fill the background (parts of
  42. the screen where objects were not drawn). In Godot 3.0, the background not only
  43. serves the purpose of displaying an image or color, it can also change how objects
  44. are affected by ambient and reflected light.
  45. .. image:: img/environment_background1.png
  46. There are many ways to set the background:
  47. - **Clear Color** uses the default clear color defined by the project. The background will be a constant color.
  48. - **Custom Color** is like Clear Color, but with a custom color value.
  49. - **Sky** lets you define a panorama sky (a 360 degree sphere texture) or a procedural sky (a simple sky featuring a gradient and an optional sun). Objects will reflect it and absorb ambient light from it.
  50. - **Color+Sky** lets you define a sky (as above), but uses a constant color value for drawing the background. The sky will only be used for reflection and ambient light.
  51. Ambient Light
  52. ^^^^^^^^^^^^^
  53. Ambient (as defined here) is a type of light that affects every piece of geometry
  54. with the same intensity. It is global and independent of lights that might be
  55. added to the scene.
  56. There are two types of ambient light: the *Ambient Color* (which is a constant
  57. color multiplied by the material albedo) and then one obtained from the *Sky*
  58. (as described before, but a sky needs to be set as background for this to be
  59. enabled).
  60. .. image:: img/environment_ambient.png
  61. When a *Sky* is set as background, it's possible to blend between ambient color
  62. and sky using the **Sky Contribution** setting (this value is 1.0 by default for
  63. convenience, so only the sky affects objects).
  64. Here is a comparison of how different ambient light affects a scene:
  65. .. image:: img/environment_ambient2.png
  66. Finally, there is an **Energy** setting, which is a multiplier. It's useful when
  67. working with HDR.
  68. In general, ambient light should only be used for simple scenes, large exteriors,
  69. or for performance reasons (ambient light is cheap), as it does not provide the
  70. best lighting quality. It's better to generate
  71. ambient light from ReflectionProbe or GIProbe, which will more faithfully simulate
  72. how indirect light propagates. Below is a comparison, in terms of quality, between using a
  73. flat ambient color and a GIProbe:
  74. .. image:: img/environment_ambient_comparison.png
  75. Using one of the methods described above, objects get constant ambient lighting
  76. replaced by ambient light from the probes.
  77. Fog
  78. ^^^
  79. Fog, as in real life, makes distant objects fade away into an uniform color. The
  80. physical effect is actually pretty complex, but Godot provides a good approximation.
  81. There are two kinds of fog in Godot:
  82. - **Depth Fog:** This one is applied based on the distance from the camera.
  83. - **Height Fog:** This one is applied to any objects below (or above) a certain height, regardless of the distance from the camera.
  84. .. image:: img/environment_fog_depth_height.png
  85. Both of these fog types can have their curve tweaked, making their transition more or less sharp.
  86. Two properties can be tweaked to make the fog effect more interesting:
  87. The first is **Sun Amount**, which makes use of the Sun Color property of the fog.
  88. When looking towards a directional light (usually a sun), the color of the fog
  89. will be changed, simulating the sunlight passing through the fog.
  90. The second is **Transmit Enabled** which simulates more realistic light transmittance.
  91. In practice, it makes light stand out more across the fog.
  92. .. image:: img/environment_fog_transmission.png
  93. Tonemap
  94. ^^^^^^^
  95. *This feature is only available when using the GLES3 backend.*
  96. Selects the tonemapping curve that will be applied to the scene, from a
  97. list of standard curves used in the film and game industry. Tonemapping operators
  98. other than Linear are used to make light and dark areas more homogeneous,
  99. while also avoiding clipping of bright highlights.
  100. The tone mapping options are:
  101. - **Mode:** The tone mapping mode to use.
  102. - **Linear:** The default tonemapping mode. This is the fastest and simplest
  103. tonemapping operator, but it causes bright lighting to look blown out, with
  104. noticeable clipping in the output colors.
  105. - **Reinhardt:** Performs a variation on rendered pixels' colors by this
  106. formula: ``color = color / (1 + color)``. This avoids clipping bright
  107. highlights, but the resulting image can look a bit dull.
  108. - **Filmic:** This avoids clipping bright highlights, with a resulting image
  109. that usually looks more vivid than Reinhardt.
  110. - **ACES Fitted:** Academy Color Encoding System tonemapper.
  111. ACES Fitted is slightly more expensive than other options, but it handles
  112. bright lighting in a more realistic fashion by desaturating it as it becomes brighter.
  113. ACES typically has a more contrasted output compared to Reinhardt and Filmic.
  114. ACES is the recommended option when aiming for photorealistic visuals.
  115. - **ACES:** *Deprecated (will be removed in Godot 4.0).* Behaves like ACES,
  116. but doesn't desaturate lighting as it becomes brighter (which is less realistic).
  117. It's recommended to use ACES Fitted instead of ACES.
  118. - **Exposure:** Tone mapping exposure which simulates amount of light received
  119. over time (default: ``1.0``). Higher values result in an overall brighter appearance.
  120. If the scene appears too dark as a result of a tonemapping operator or whitepoint
  121. change, try increasing this value slightly.
  122. - **White:** Tone mapping whitepoint, which simulates where in the scale white is
  123. located (default: ``1.0``). For photorealistic lighting, recommended values are
  124. between ``6.0`` and ``8.0``. Higher values result in less blown out highlights,
  125. but make the scene appear slightly darker as a whole.
  126. Auto Exposure (HDR)
  127. ^^^^^^^^^^^^^^^^^^^
  128. *This feature is only available when using the GLES3 backend.*
  129. Even though, in most cases, lighting and texturing are heavily artist controlled,
  130. Godot supports a simple high dynamic range implementation with the auto exposure
  131. mechanism. This is generally used for the sake of realism when combining
  132. interior areas with low light and outdoors. Auto exposure simulates the camera
  133. (or eye) in an effort to adapt between light and dark locations and their
  134. different amounts of light.
  135. .. image:: img/environment_hdr_autoexp.gif
  136. The simplest way to use auto exposure is to make sure outdoor lights (or other
  137. strong lights) have energy beyond 1.0. This is done by tweaking their **Energy**
  138. multiplier (on the Light itself). To make it consistent, the **Sky** usually
  139. needs to use the energy multiplier too, to match with the directional light.
  140. Normally, values between 3.0 and 6.0 are enough to simulate indoor-outdoor conditions.
  141. By combining Auto Exposure with *Glow* post processing (more on that below),
  142. pixels that go over the tonemap **White** will bleed to the glow buffer,
  143. creating the typical bloom effect in photography.
  144. .. image:: img/environment_hdr_bloom.png
  145. The user-controllable values in the Auto Exposure section come with sensible
  146. defaults, but you can still tweak them:
  147. .. image:: img/environment_hdr.png
  148. - **Scale:** Value to scale the lighting. Brighter values produce brighter images, smaller ones produce darker ones.
  149. - **Min Luma:** Minimum luminance that auto exposure will aim to adjust for. Luminance is the average of the light in all the pixels of the screen.
  150. - **Max Luma:** Maximum luminance that auto exposure will aim to adjust for.
  151. - **Speed:** Speed at which luminance corrects itself. The higher the value, the faster correction happens.
  152. Mid- and post-processing effects
  153. --------------------------------
  154. A large amount of widely-used mid- and post-processing effects are supported
  155. in the Environment.
  156. Screen-Space Reflections (SSR)
  157. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  158. *This feature is only available when using the GLES3 backend.*
  159. While Godot supports three sources of reflection data (Sky, ReflectionProbe, and
  160. GIProbe), they may not provide enough detail for all situations. Scenarios
  161. where Screen Space Reflections make the most sense are when objects are in
  162. contact with each other (object over floor, over a table, floating on water, etc).
  163. .. image:: img/environment_ssr.png
  164. The other advantage (even if only enabled to a minimum), is that it works in real-time
  165. (while the other types of reflections are pre-computed). This can be used to
  166. make characters, cars, etc. reflect on surrounding surfaces when moving around.
  167. A few user-controlled parameters are available to better tweak the technique:
  168. - **Max Steps** determines the length of the reflection. The bigger this number, the more costly it is to compute.
  169. - **Fade In** allows adjusting the fade-in curve, which is useful to make the contact area softer.
  170. - **Fade Out** allows adjusting the fade-out curve, so the step limit fades out softly.
  171. - **Depth Tolerance** can be used for screen-space-ray hit tolerance to gaps. The bigger the value, the more gaps will be ignored.
  172. - **Roughness** will apply a screen-space blur to approximate roughness in objects with this material characteristic.
  173. Keep in mind that screen-space-reflections only work for reflecting opaque geometry. Transparent objects can't be reflected.
  174. Screen-Space Ambient Occlusion (SSAO)
  175. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  176. *This feature is only available when using the GLES3 backend.*
  177. As mentioned in the **Ambient** section, areas where light from light nodes
  178. does not reach (either because it's outside the radius or shadowed) are lit
  179. with ambient light. Godot can simulate this using GIProbe, ReflectionProbe,
  180. the Sky, or a constant ambient color. The problem, however, is that all the
  181. methods proposed previously act more on a larger scale (large regions) than at the
  182. smaller geometry level.
  183. Constant ambient color and Sky are the same everywhere, while GI and
  184. Reflection probes have more local detail, but not enough to simulate situations
  185. where light is not able to fill inside hollow or concave features.
  186. This can be simulated with Screen Space Ambient Occlusion. As you can see in the
  187. image below, its purpose is to make sure concave areas are darker, simulating
  188. a narrower path for the light to enter:
  189. .. image:: img/environment_ssao.png
  190. It is a common mistake to enable this effect, turn on a light, and not be able to
  191. appreciate it. This is because SSAO only acts on *ambient* light, not direct light.
  192. This is why, in the image above, the effect is less noticeable under the direct
  193. light (on the left). If you want to force SSAO to work with direct light too, use
  194. the **Light Affect** parameter (even though this is not correct, some artists like how it looks).
  195. SSAO looks best when combined with a real source of indirect light, like GIProbe:
  196. .. image:: img/environment_ssao2.png
  197. Tweaking SSAO is possible with several parameters:
  198. .. image:: img/environment_ssao_parameters.png
  199. - **Radius/Intensity:** To control the radius or intensity of the occlusion, these two parameters are available. Radius is in world (Metric) units.
  200. - **Radius2/Intensity2:** A Secondary radius/intensity can be used. Combining a large and a small radius AO generally works well.
  201. - **Bias:** This can be tweaked to solve self occlusion, though the default generally works well enough.
  202. - **Light Affect:** SSAO only affects ambient light, but increasing this slider can make it also affect direct light. Some artists prefer this effect.
  203. - **Ao Channel Affect:** If a value of zero is used, only the material's AO texture will be used for ambient occlusion; SSAO will not be applied. Values greater than 0 multiply the AO texture by the SSAO effect to varying degrees. This does not affect materials without an AO texture.
  204. - **Quality:** Depending on quality, SSAO will take more samples over a sphere for every pixel. High quality only works well on modern GPUs.
  205. - **Blur:** Type of blur kernel used. The 1x1 kernel is a simple blur that preserves local detail better, but is not as efficient (generally works better with the high quality setting above), while 3x3 will soften the image better (with a bit of dithering-like effect), but does not preserve local detail as well.
  206. - **Edge Sharpness**: This can be used to preserve the sharpness of edges (avoids areas without AO on creases).
  207. Depth of Field / Far Blur
  208. ^^^^^^^^^^^^^^^^^^^^^^^^^
  209. This effect simulates focal distance on high end cameras. It blurs objects behind
  210. a given range. It has an initial **Distance** with a **Transition** region
  211. (in world units):
  212. .. image:: img/environment_dof_far.png
  213. The **Amount** parameter controls the amount of blur. For larger blurs, tweaking
  214. the **Quality** may be needed in order to avoid artifacts.
  215. Depth of Field / Near Blur
  216. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  217. This effect simulates focal distance on high end cameras. It blurs objects close
  218. to the camera (acts in the opposite direction as far blur).
  219. It has an initial **Distance** with a **Transition** region (in world units):
  220. .. image:: img/environment_dof_near.png
  221. The **Amount** parameter controls the amount of blur. For larger blurs, tweaking
  222. the **Quality** may be needed in order to avoid artifacts.
  223. It is common to use both blurs together to focus the viewer's attention on a
  224. given object:
  225. .. image:: img/environment_mixed_blur.png
  226. Glow
  227. ^^^^
  228. In photography and film, when light amount exceeds the maximum supported by the
  229. media (be it analog or digital), it generally bleeds outwards to darker regions
  230. of the image. This is simulated in Godot with the **Glow** effect.
  231. .. image:: img/environment_glow1.png
  232. By default, even if the effect is enabled, it will be weak or invisible. One of
  233. two conditions need to happen for it to actually show:
  234. - 1) The light in a pixel surpasses the **HDR Threshold** (where 0 is all light surpasses it, and 1.0 is light over the tonemapper **White** value). Normally, this value is expected to be at 1.0, but it can be lowered to allow more light to bleed. There is also an extra parameter, **HDR Scale**, that allows scaling (making brighter or darker) the light surpassing the threshold.
  235. .. image:: img/environment_glow_threshold.png
  236. - 2) The Bloom effect has a value set greater than 0. As it increases, it sends the whole screen to the glow processor at higher amounts.
  237. .. image:: img/environment_glow_bloom.png
  238. Both will cause the light to start bleeding out of the brighter areas.
  239. Once glow is visible, it can be controlled with a few extra parameters:
  240. - **Intensity** is an overall scale for the effect, it can be made stronger or weaker (0.0 removes it).
  241. - **Strength** is how strong the gaussian filter kernel is processed. Greater values make the filter saturate and expand outwards. In general, changing this is not needed, as the size can be more efficiently adjusted with the **Levels**.
  242. The **Blend Mode** of the effect can also be changed:
  243. - **Additive** is the strongest one, as it only adds the glow effect over the image with no blending involved. In general, it's too strong to be used, but can look good with low intensity Bloom (produces a dream-like effect).
  244. - **Screen** ensures glow never brightens more than itself and it works great as an all around.
  245. - **Softlight** is the default and weakest one, producing only a subtle color disturbance around the objects. This mode works best on dark scenes.
  246. - **Replace** can be used to blur the whole screen or debug the effect. It only shows the glow effect without the image below.
  247. To change the glow effect size and shape, Godot provides **Levels**. Smaller
  248. levels are strong glows that appear around objects, while large levels are hazy
  249. glows covering the whole screen:
  250. .. image:: img/environment_glow_layers.png
  251. The real strength of this system, though, is to combine levels to create more
  252. interesting glow patterns:
  253. .. image:: img/environment_glow_layers2.png
  254. Finally, as the highest layers are created by stretching small blurred images,
  255. it is possible that some blockiness may be visible. Enabling **Bicubic Upscaling**
  256. gets rids of it, at a minimal performance cost.
  257. *Note that this is effective only when using the GLES3 backend.*
  258. .. image:: img/environment_glow_bicubic.png
  259. Adjustments
  260. ^^^^^^^^^^^
  261. At the end of processing, Godot offers the possibility to do some standard
  262. image adjustments.
  263. .. image:: img/environment_adjustments.png
  264. The first one is being able to change the typical Brightness, Contrast,
  265. and Saturation:
  266. .. image:: img/environment_adjustments_bcs.png
  267. The second is by supplying a color correction gradient. A regular black to
  268. white gradient like the following one will produce no effect:
  269. .. image:: img/environment_adjusments_default_gradient.png
  270. But creating custom ones will allow to map each channel to a different color:
  271. .. image:: img/environment_adjusments_custom_gradient.png