Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions tutorials/3d/lights_and_shadows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,40 @@ There is a list of generic shadow parameters, each also has a specific function:
- **Color**: Areas occluded are multiplied by this color. It is black by default, but it can be changed to tint shadows.
- **Bias**: When this parameter is too small, self shadowing occurs. When too large, shadows separate from the casters. Tweak to what works best for you.
- **Contact**: Performs a short screen-space raycast to reduce the gap generated by the bias. Contact shadows are only available when using the GLES3 backend.
- **Reverse Cull Faces**: Some scenes work better when shadow mapping is rendered with face-culling inverted.
- **Reverse Cull Face**: Some scenes work better when shadow mapping is rendered with face-culling inverted.

Below is an image of what tweaking bias looks like. Default values work for most
cases, but in general it depends on the size and complexity of geometry.

.. image:: img/shadow_bias.png

Finally, if gaps can't be solved, the **Contact** option can help:
Finally, if gaps can't be solved, the **Contact** option can help (at a performance cost):

.. image:: img/shadow_contact.png

Any sort of bias issues can always be fixed by increasing the shadow map resolution,
although that may lead to decreased performance on low-end hardware.
although that may lead to decreased performance.

.. tip::

If shadow biasing is a problem in your scene, the following settings are a good starting point:

- Enable **Reverse Cull Face**. This reduces shadow peter-panning significantly
and prevents lights from exhibiting shadow acne at grazing angles.
The main downside is that it may cause lighting to leak in some corners.
The other downside is that materials that have their cull mode set to
**Disabled** or MeshInstances with Cast Shadow set to **Double-Sided**
will exhibit shadow acne.
- Set **Bias** to ``-0.01``. The bias should be a negative value when
**Reverse Cull Face** is enabled, but it should be a positive value when it's disabled.
- For DirectionalLight, set the directional shadow **Normal Bias** to ``0.0``
and **Bias Split Scale** to ``0.0``. Depending on your scene, you may also
want to further decrease **Bias** to a value between ``-0.05`` and ``-0.1``.

Following the above tips should make it possible to avoid gaps in shadows without
resorting to contact shadows (which have many issues of their own).
If shadow acne is still visible after performing the above tweaks,
try subdividing your meshes further in your 3D modeling software.

Directional light
~~~~~~~~~~~~~~~~~
Expand Down