lights_and_shadows.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. .. _doc_lights_and_shadows:
  2. 3D lights and shadows
  3. =====================
  4. Introduction
  5. ------------
  6. Light sources emit light that mixes with the materials and produces a visible
  7. result. Light can come from several types of sources in a scene:
  8. - From the material itself, in the form of the emission color (though it does
  9. not affect nearby objects unless baked or screen-space indirect lighting is enabled).
  10. - Light nodes: DirectionalLight3D, OmniLight3D and SpotLight3D.
  11. - Ambient light in the :ref:`Environment <class_Environment>` or
  12. :ref:`doc_reflection_probes`.
  13. - Global illumination (:ref:`LightmapGI <doc_using_lightmap_gi>`,
  14. :ref:`VoxelGI <doc_using_voxel_gi>` or :ref:`SDFGI <doc_using_sdfgi>`).
  15. The emission color is a material property. You can read more about it
  16. in the :ref:`doc_standard_material_3d` tutorial.
  17. .. seealso::
  18. You can compare various types of lights in action using the
  19. `3D Lights and Shadows demo project <https://github.com/godotengine/godot-demo-projects/tree/master/3d/lights_and_shadows>`__.
  20. Light nodes
  21. -----------
  22. There are three types of light nodes: :ref:`class_DirectionalLight3D`,
  23. :ref:`class_OmniLight3D` and :ref:`class_SpotLight3D`. Let's take a look at the common
  24. parameters for lights:
  25. .. image:: img/light_params.png
  26. Each property has a specific function:
  27. - **Color:** Base color for emitted light.
  28. - **Energy:** Energy multiplier. This is useful for saturating lights or working with :ref:`doc_high_dynamic_range`.
  29. - **Indirect Energy:** Secondary multiplier used with indirect light (light bounces). This works with :ref:`doc_using_lightmap_gi`, VoxelGI or SDFGI.
  30. - **Volumetric Fog Energy:** Secondary multiplier used with volumetric fog. This only has an effect when volumetric fog is enabled.
  31. - **Negative:** Light becomes subtractive instead of additive. It's sometimes useful to manually compensate some dark corners.
  32. - **Specular:** Affects the intensity of the specular blob in objects affected by this light. At zero, this light becomes a pure diffuse light.
  33. - **Bake Mode:** Sets the bake mode for the light. See :ref:`doc_using_lightmap_gi`.
  34. - **Cull Mask:** Objects that are in the selected layers below will be affected by this light.
  35. Note that objects disabled via this cull mask will still cast shadows.
  36. If you don't want disabled objects to cast shadows, adjust the **Cast Shadow**
  37. property on the GeometryInstance3D to the desired value.
  38. .. seealso::
  39. See :ref:`doc_physical_light_and_camera_units` if you wish to use real world
  40. units to configure your lights' intensity and color temperature.
  41. Light number limits
  42. -------------------
  43. When using the Forward+ renderer, Godot uses a *clustering* approach for
  44. real-time lighting. As many lights as desired can be added (as long as
  45. performance allows). However, there's still a default limit of 512 *clustered
  46. elements* that can be present in the current camera view. A clustered element is
  47. an omni light, a spot light, a :ref:`decal <doc_using_decals>` or a
  48. :ref:`reflection probe <doc_reflection_probes>`. This limit can be increased by adjusting
  49. :ref:`Max Clustered Elements<class_ProjectSettings_property_rendering/limits/cluster_builder/max_clustered_elements>`
  50. in **Project Settings > Rendering > Limits > Cluster Builder**.
  51. When using the Forward Mobile renderer, there is a limitation of 8 OmniLights +
  52. 8 SpotLights per mesh resource. There is also a limit of 256 OmniLights + 256
  53. SpotLights that can be rendered in the current camera view. These limits
  54. currently cannot be changed.
  55. When using the Compatibility renderer, up to 8 OmniLights + 8 SpotLights can be
  56. rendered per mesh resource. This limit can be increased in the advanced Project
  57. Settings by adjusting
  58. :ref:`Max Renderable Elements<class_ProjectSettings_property_rendering/limits/opengl/max_renderable_elements>`
  59. and/or :ref:`Max Lights per Object<class_ProjectSettings_property_rendering/limits/opengl/max_lights_per_object>`
  60. in **Rendering > Limits > OpenGL**, at the cost of performance and longer shader
  61. compilation times. The limit can also be decreased to reduce shader compilation
  62. times and improve performance slightly.
  63. With all rendering methods, up to 8 DirectionalLights can be visible at a time.
  64. However, each additional DirectionalLight with shadows enabled will reduce the
  65. effective shadow resolution of each DirectionalLight. This is because
  66. directional shadow atlas is shared between all lights.
  67. If the rendering limit is exceeded, lights will start popping in and out during
  68. camera movement, which can be distracting. Enabling **Distance Fade** on light
  69. nodes can help reduce this issue while also improving performance. Splitting
  70. your meshes into smaller portions can also help, especially for level geometry
  71. (which also improves culling efficiency).
  72. If you need to render more lights than possible in a given rendering backend,
  73. consider using :ref:`baked lightmaps <doc_using_lightmap_gi>` with lights' bake
  74. mode set to **Static**. This allows lights to be fully baked, which also makes
  75. them much faster to render. You can also use emissive materials with any
  76. :ref:`global illumination <doc_introduction_to_global_illumination>` technique
  77. as a replacement for light nodes that emit light over a large area.
  78. Shadow mapping
  79. --------------
  80. Lights can optionally cast shadows. This gives them greater realism (light does
  81. not reach occluded areas), but it can incur a bigger performance cost.
  82. There is a list of generic shadow parameters, each also has a specific function:
  83. - **Enabled:** Check to enable shadow mapping in this light.
  84. - **Opacity:** Areas occluded are darkened by this opacity factor. Shadows are
  85. fully opaque by default, but this can be changed to make shadows translucent
  86. for a given light.
  87. - **Bias:** When this parameter is too low, self-shadowing occurs. When too
  88. high, shadows separate from the casters. Tweak to what works best for you.
  89. - **Normal Bias:** When this parameter is too low, self-shadowing occurs. When too
  90. high, shadows appear misaligned from the casters. Tweak to what works best for you.
  91. - **Transmittance Bias:** When this parameter is too low, self-shadowing
  92. occurs on materials that have transmittance enabled. When too high, shadows
  93. will not affect materials that have transmittance enabled consistently. Tweak
  94. to what works best for you.
  95. - **Reverse Cull Face:** Some scenes work better when shadow mapping is rendered
  96. with face-culling inverted.
  97. - **Blur:** Multiplies the shadow blur radius for this light. This works with
  98. both traditional shadow mapping and contact-hardening shadows (lights with
  99. **Angular Distance** or **Size** greater than ``0.0``). Higher values result
  100. in softer shadows, which will also appear to be more temporally stable for
  101. moving objects. The downside of increasing shadow blur is that it will make
  102. the grainy pattern used for filtering more noticeable.
  103. See also :ref:`doc_lights_and_shadows_shadow_filter_mode`.
  104. - **Caster Mask:** Shadows are only cast by objects in these layers. Note that
  105. this mask does not affect which objects shadows are cast *onto*.
  106. .. image:: img/lights_and_shadows_blur.webp
  107. Tweaking shadow bias
  108. ^^^^^^^^^^^^^^^^^^^^
  109. Below is an image of what tweaking bias looks like. Default values work for most
  110. cases, but in general, it depends on the size and complexity of geometry.
  111. If the **Shadow Bias** or **Shadow Normal Bias** is set too low for a given light,
  112. the shadow will be "smeared" onto the objects. This will cause the light's
  113. intended appearance to darken, and is called *shadow acne*:
  114. .. image:: img/lights_and_shadows_acne.webp
  115. On the other hand, if the **Shadow Bias** or **Shadow Normal Bias** is set too
  116. high for a given light, the shadow may appear to be disconnected from the
  117. object. This is called *peter-panning*:
  118. .. image:: img/lights_and_shadows_peter_panning.webp
  119. In general, increasing **Shadow Normal Bias** is preferred over increasing
  120. **Shadow Bias**. Increasing **Shadow Normal Bias** does not cause as much
  121. peter-panning as increasing **Shadow Bias**, but it can still resolve
  122. most shadow acne issues efficiently. The downside of increasing **Shadow Normal
  123. Bias** is that it can make shadows appear thinner for certain objects.
  124. Any sort of bias issues can be fixed by
  125. :ref:`increasing the shadow map resolution <doc_lights_and_shadows_balancing_performance_and_quality>`,
  126. at the cost of decreased performance.
  127. .. note::
  128. Tweaking shadow mapping settings is an art – there are no "one size fits
  129. all" settings. To achieve the best visuals, you may need to use different
  130. shadow bias values on a per-light basis.
  131. **Note on Appearance Changes**: When enabling shadows on a light, be aware that the light's
  132. appearance might change compared to when it's rendered without shadows in the compatibility
  133. renderer. Due to limitations with older mobile devices, shadows are implemented using a multi-pass
  134. rendering approach so lights with shadows are rendered in sRGB space instead of linear space.
  135. This change in rendering space can sometimes drastically alter the light's appearance. To achieve a similar
  136. appearance to an unshadowed light, you may need to adjust the light's energy setting.
  137. Directional light
  138. -----------------
  139. This is the most common type of light and represents a light source very far
  140. away (such as the sun). It is also the cheapest light to compute and should be
  141. used whenever possible (although it's not the cheapest shadow-map to compute,
  142. but more on that later).
  143. Directional light models an infinite number of parallel light rays
  144. covering the whole scene. The directional light node is represented by a big arrow which
  145. indicates the direction of the light rays. However, the position of the node
  146. does not affect the lighting at all and can be anywhere.
  147. .. image:: img/light_directional.png
  148. Every face whose front-side is hit by the light rays is lit, while the others
  149. stay dark. Unlike most other light types, directional lights don't have specific
  150. parameters.
  151. The directional light also offers a **Angular Distance** property, which
  152. determines the light's angular size in degrees. Increasing this above ``0.0``
  153. will make shadows softer at greater distances from the caster, while also
  154. affecting the sun's appearance in procedural sky materials. This is called a
  155. *contact-hardening* shadow (also known as PCSS).
  156. For reference, the angular distance of the Sun viewed from the Earth is
  157. approximately ``0.5``. This kind of shadow is expensive, so check the
  158. recommendations in :ref:`doc_lights_and_shadows_pcss_recommendations` if setting
  159. this value above ``0.0`` on lights with shadows enabled.
  160. Directional shadow mapping
  161. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  162. To compute shadow maps, the scene is rendered (only depth) from an orthogonal
  163. point of view that covers the whole scene (or up to the max distance). There is,
  164. however, a problem with this approach because objects closer to the camera
  165. receive low-resolution shadows that may appear blocky.
  166. To fix this, a technique named *Parallel Split Shadow Maps* (PSSM) is used.
  167. This splits the view frustum in 2 or 4 areas. Each area gets its own shadow map.
  168. This allows small areas close to the viewer to have the same shadow resolution
  169. as a huge, far-away area. When shadows are enabled for DirectionalLight3D, the
  170. default shadow mode is PSSM with 4 splits. In scenarios where an object is large
  171. enough to appear in all four splits, it results in increased draw calls. Specifically,
  172. such an object will be rendered five times in total: once for each of the four shadow
  173. splits and once for the final scene rendering. This can impact performance, understanding
  174. this behavior is important for optimizing your scene and managing performance expectations.
  175. .. image:: img/lights_and_shadows_pssm_explained.webp
  176. With this, shadows become more detailed:
  177. .. image:: img/lights_and_shadows_directional_mode.webp
  178. To control PSSM, a number of parameters are exposed:
  179. .. image:: img/lights_and_shadows_directional_shadow_params.webp
  180. Each split distance is controlled relative to the camera far (or shadow
  181. **Max Distance** if greater than ``0.0``). ``0.0`` is the eye position and
  182. ``1.0`` is where the shadow ends at a distance. Splits are in-between.
  183. Default values generally work well, but tweaking the first split a bit is common
  184. to give more detail to close objects (like a character in a third-person game).
  185. Always make sure to set a shadow **Max Distance** according to what the scene
  186. needs. A lower maximum distance will result in better-looking shadows and better
  187. performance, as fewer objects will need to be included in shadow rendering. You
  188. can also adjust **Fade Start** to control how aggressive the shadow fade-out
  189. should be at a distance. For scenes where the **Max Distance** fully covers the
  190. scene at any given camera position, you can increase **Fade Start** to ``1.0``
  191. to prevent the shadow from fading at a distance. This should not be done in
  192. scenes where **Max Distance** doesn't fully cover the scene, as the shadow will
  193. appear to be suddenly cut off at a distance.
  194. Sometimes, the transition between a split and the next can look bad. To fix
  195. this, the **Blend Splits** option can be turned on, which sacrifices detail and
  196. performance in exchange for smoother transitions:
  197. .. image:: img/blend_splits.png
  198. The **Shadow > Normal Bias** parameter can be used to fix special cases of
  199. self-shadowing when objects are perpendicular to the light. The only downside is
  200. that it makes the shadow a bit thinner. Consider increasing **Shadow > Normal
  201. Bias** before increasing **Shadow > Bias** in most situations.
  202. Lastly, **Pancake Size** is a property that can be adjusted to fix missing
  203. shadows when using large objects with unsubdivided meshes. Only change this
  204. value if you notice missing shadows that are not related to shadow biasing
  205. issues.
  206. Omni light
  207. ----------
  208. Omni light is a point source that emits light spherically in all directions up to a given
  209. radius.
  210. .. image:: img/light_omni.png
  211. In real life, light attenuation is an inverse function, which means omni lights don't have a radius.
  212. This is a problem because it means computing several omni lights would become demanding.
  213. To solve this, a **Range** parameter is introduced together with an attenuation function.
  214. .. image:: img/light_omni_params.png
  215. These two parameters allow tweaking how this works visually in order to find aesthetically pleasing results.
  216. .. image:: img/light_attenuation.png
  217. A **Size** parameter is also available in OmniLight3D. Increasing this value
  218. will make the light fade out slower and shadows appear blurrier when far away
  219. from the caster. This can be used to simulate area lights to an extent. This is
  220. called a *contact-hardening* shadow (also known as PCSS). This kind of shadow is
  221. expensive, so check the recommendations in
  222. :ref:`doc_lights_and_shadows_pcss_recommendations` if setting this value above
  223. ``0.0`` on lights with shadows enabled.
  224. .. image:: img/lights_and_shadows_pcss.webp
  225. Omni shadow mapping
  226. ^^^^^^^^^^^^^^^^^^^
  227. Omni light shadow mapping is relatively straightforward. The main issue that
  228. needs to be considered is the algorithm used to render it.
  229. Omni Shadows can be rendered as either **Dual Paraboloid** or **Cube** mapped.
  230. **Dual Parabolid** renders quickly, but can cause deformations, while **Cube**
  231. is more correct, but slower. The default is **Cube**, but consider changing it
  232. to **Dual Parabolid** for lights where it doesn't make much of a visual
  233. difference.
  234. .. image:: img/lights_and_shadows_dual_parabolid_vs_cubemap.webp
  235. If the objects being rendered are mostly irregular and subdivided, Dual
  236. Paraboloid is usually enough. In any case, as these shadows are cached in a
  237. shadow atlas (more on that at the end), it may not make a difference in
  238. performance for most scenes.
  239. Omni lights with shadows enabled can make use of projectors. The projector
  240. texture will *multiply* the light's color by the color at a given point on the
  241. texture. As a result, lights will usually appear to be darker once a projector
  242. texture is assigned; you can increase **Energy** to compensate for this.
  243. Omni light projector textures require a special 360° panorama mapping, similar
  244. to :ref:`class_PanoramaSkyMaterial` textures.
  245. With the projector texture below, the following result is obtained:
  246. .. image:: img/lights_and_shadows_omni_projector_example.webp
  247. .. image:: img/lights_and_shadows_omni_projector.webp
  248. .. tip::
  249. If you've acquired omni projectors in the form of cubemap images, you can use
  250. `this web-based conversion tool <https://danilw.github.io/GLSL-howto/cubemap_to_panorama_js/cubemap_to_panorama.html>`__
  251. to convert them to a single panorama image.
  252. Spot light
  253. ----------
  254. Spot lights are similar to omni lights, except they emit light only into a cone
  255. (or "cutoff"). They are useful to simulate flashlights,
  256. car lights, reflectors, spots, etc. This type of light is also attenuated towards the
  257. opposite direction it points to.
  258. Spot lights share the same **Range**, **Attenuation** and **Size** as OmniLight3D,
  259. and add two extra parameters:
  260. - **Angle:** The aperture angle of the light.
  261. - **Angle Attenuation:** The cone attenuation, which helps soften the cone borders.
  262. Spot shadow mapping
  263. ^^^^^^^^^^^^^^^^^^^
  264. Spots feature the same parameters as omni lights for shadow mapping. Rendering
  265. spot shadow maps is significantly faster compared to omni lights, as only one
  266. shadow texture needs to be rendered (instead of rendering 6 faces, or 2 in dual
  267. parabolid mode).
  268. Spot lights with shadows enabled can make use of projectors. The projector
  269. texture will *multiply* the light's color by the color at a given point on the
  270. texture. As a result, lights will usually appear to be darker once a projector
  271. texture is assigned; you can increase **Energy** to compensate for this.
  272. Unlike omni light projectors, a spot light projector texture doesn't need to
  273. follow a special format to look correct. It will be mapped in a way similar to a
  274. :ref:`decal <doc_using_decals>`.
  275. With the projector texture below, the following result is obtained:
  276. .. image:: img/lights_and_shadows_spot_projector_example.webp
  277. .. image:: img/lights_and_shadows_spot_projector.webp
  278. .. note::
  279. Spot lights with wide angles will have lower-quality shadows than spot
  280. lights with narrow angles, as the shadow map is spread over a larger
  281. surface. At angles wider than 89 degrees, spot light shadows will stop
  282. working entirely. If you need shadows for wider lights, use an omni light
  283. instead.
  284. .. _doc_lights_and_shadows_shadow_atlas:
  285. Shadow atlas
  286. ------------
  287. Unlike Directional lights, which have their own shadow texture, omni and spot
  288. lights are assigned to slots of a shadow atlas. This atlas can be configured in
  289. the advanced Project Settings (**Rendering > Lights And Shadows > Positional Shadow**).
  290. The resolution applies to the whole shadow atlas. This atlas is divided into four quadrants:
  291. .. image:: img/lights_and_shadows_shadow_quadrants.webp
  292. Each quadrant can be subdivided to allocate any number of shadow maps; the following is the default subdivision:
  293. .. image:: img/lights_and_shadows_shadow_quadrants2.webp
  294. The shadow atlas allocates space as follows:
  295. - The biggest shadow map size (when no subdivision is used) represents a light the size of the screen (or bigger).
  296. - Subdivisions (smaller maps) represent shadows for lights that are further away from view and proportionally smaller.
  297. Every frame, the following procedure is performed for all lights:
  298. 1. Check if the light is on a slot of the right size. If not, re-render it and move it to a larger/smaller slot.
  299. 2. Check if any object affecting the shadow map has changed. If it did, re-render the light.
  300. 3. If neither of the above has happened, nothing is done, and the shadow is left untouched.
  301. If the slots in a quadrant are full, lights are pushed back to smaller slots,
  302. depending on size and distance. If all slots in all quadrants are full, some
  303. lights will not be able to render shadows even if shadows are enabled on them.
  304. The default shadow allocation strategy allows rendering up to 88 lights with
  305. shadows enabled in the camera frustum (4 + 4 + 16 + 64):
  306. 1. The first and most detailed quadrant can store 4 shadows.
  307. 2. The second quadrant can store 4 other shadows.
  308. 3. The third quadrant can store 16 shadows, with less detail.
  309. 4. The fourth and least detailed quadrant can store 64 shadows, with even less detail.
  310. Using a higher number of shadows per quadrant allows supporting a greater amount
  311. of total lights with shadows enabled, while also improving performance (as
  312. shadows will be rendered at a lower resolution for each light). However,
  313. increasing the number of shadows per quadrant comes at the cost of lower shadow
  314. quality.
  315. In some cases, you may want to use a different allocation strategy. For example,
  316. in a top-down game where all lights are around the same size, you may want to
  317. set all quadrants to have the same subdivision so that all lights have shadows
  318. of similar quality level.
  319. .. _doc_lights_and_shadows_balancing_performance_and_quality:
  320. Balancing performance and quality
  321. ---------------------------------
  322. Shadow rendering is a critical topic in 3D rendering performance. It's important
  323. to make the right choices here to avoid creating bottlenecks.
  324. Directional shadow quality settings can be changed at runtime by calling the
  325. appropriate :ref:`class_RenderingServer` methods.
  326. Positional (omni/spot) shadow quality settings can be changed at runtime on the
  327. root :ref:`class_Viewport`.
  328. Shadow map size
  329. ^^^^^^^^^^^^^^^
  330. High shadow resolutions result in sharper shadows, but at a significant
  331. performance cost. It should also be noted that *sharper shadows are not always
  332. more realistic*. In most cases, this should be kept at its default value of
  333. ``4096`` or decreased to ``2048`` for low-end GPUs.
  334. If positional shadows become too blurry after decreasing the shadow map size,
  335. you can counteract this by adjusting the
  336. :ref:`shadow atlas <doc_lights_and_shadows_shadow_atlas>` quadrants to contain
  337. fewer shadows. This will allow each shadow to be rendered at a higher resolution.
  338. .. _doc_lights_and_shadows_shadow_filter_mode:
  339. Shadow filter mode
  340. ^^^^^^^^^^^^^^^^^^
  341. Several shadow map quality settings can be chosen here. The default **Soft Low**
  342. is a good balance between performance and quality for scenes with detailed
  343. textures, as the texture detail will help make the dithering pattern less noticeable.
  344. However, in projects with less detailed textures, the shadow dithering pattern
  345. may be more visible. To hide this pattern, you can either enable
  346. :ref:`doc_3d_antialiasing_taa`, :ref:`doc_3d_antialiasing_fsr2`,
  347. :ref:`doc_3d_antialiasing_fxaa`, or increase the shadow filter quality to
  348. **Soft Medium** or higher.
  349. The **Soft Very Low** setting will automatically decrease shadow blur to make
  350. artifacts from the low sample count less visible. Conversely, the **Soft High**
  351. and **Soft Ultra** settings will automatically increase shadow blur to better
  352. make use of the increased sample count.
  353. .. image:: img/lights_and_shadows_filter_quality.webp
  354. 16-bits versus 32-bit
  355. ^^^^^^^^^^^^^^^^^^^^^
  356. By default, Godot uses 16-bit depth textures for shadow map rendering. This is
  357. recommended in most cases as it performs better without a noticeable difference
  358. in quality.
  359. If **16 Bits** is disabled, 32-bit depth textures will be used instead. This
  360. can result in less artifacting in large scenes and large lights with shadows
  361. enabled. However, the difference is often barely visible, yet this can have a
  362. significant performance cost.
  363. Light/shadow distance fade
  364. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  365. OmniLight3D and SpotLight3D offer several properties to hide distant lights.
  366. This can improve performance significantly in large scenes with dozens of lights
  367. or more.
  368. - **Enabled:** Controls whether distance fade (a form of :abbr:`LOD (Level of Detail)`)
  369. is enabled. The light will fade out over **Begin + Length**, after which it
  370. will be culled and not sent to the shader at all. Use this to reduce the number
  371. of active lights in a scene and thus improve performance.
  372. - **Begin:** The distance from the camera at which the light begins to fade away
  373. (in 3D units).
  374. - **Shadow:** The distance from the camera at which the shadow begins to fade away
  375. (in 3D units). This can be used to fade out shadows sooner compared to the light,
  376. further improving performance. Only available if shadows are enabled for the light.
  377. - **Length:** The distance over which the light and shadow fades (in 3D units).
  378. The light becomes slowly more transparent over this distance and is completely
  379. invisible at the end. Higher values result in a smoother fade-out transition,
  380. which is more suited when the camera moves fast.
  381. .. _doc_lights_and_shadows_pcss_recommendations:
  382. PCSS recommendations
  383. ^^^^^^^^^^^^^^^^^^^^
  384. Percentage-closer soft shadows (PCSS) provide a more realistic shadow mapping
  385. appearance, with the penumbra size varying depending on the distance between the
  386. caster and the surface receiving the shadow. This comes at a high performance
  387. cost, especially for directional lights.
  388. To avoid performance issues, it's recommended to:
  389. - Only use a handful of lights with PCSS shadows enabled at a given time. The
  390. effect is generally most visible on large, bright lights. Secondary light
  391. sources that are more faint usually don't benefit much from using PCSS
  392. shadows.
  393. - Provide a setting for users to disable PCSS shadows. On directional lights,
  394. this can be done by setting the DirectionalLight3D's
  395. ``light_angular_distance`` property to ``0.0`` in a script. On positional
  396. lights, this can be done by setting the OmniLight3D or SpotLight3D's
  397. ``light_size`` property to ``0.0`` in a script.
  398. Projector filter mode
  399. ^^^^^^^^^^^^^^^^^^^^^
  400. The way projectors are rendered also has an impact on performance. The
  401. **Rendering > Textures > Light Projectors > Filter** advanced project setting
  402. lets you control how projector textures should be filtered. **Nearest/Linear** do
  403. not use mipmaps, which makes them faster to render. However, projectors will
  404. look grainy at distance. **Nearest/Linear Mipmaps** will look smoother at a
  405. distance, but projectors will look blurry when viewed from oblique angles. This
  406. can be resolved by using **Nearest/Linear Mipmaps Anisotropic**, which is the
  407. highest-quality mode, but also the most expensive.
  408. If your project has a pixel art style, consider setting the filter to one of the
  409. **Nearest** values so that projectors use nearest-neighbor filtering. Otherwise,
  410. stick to **Linear**.