Skip to content

Commit 294c489

Browse files
committed
Add recommendations for 3D light shadow bias
These are the settings I usually recommend based on my personal experience.
1 parent eed6a9e commit 294c489

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tutorials/3d/lights_and_shadows.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,35 @@ There is a list of generic shadow parameters, each also has a specific function:
5252
- **Color**: Areas occluded are multiplied by this color. It is black by default, but it can be changed to tint shadows.
5353
- **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.
5454
- **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.
55-
- **Reverse Cull Faces**: Some scenes work better when shadow mapping is rendered with face-culling inverted.
55+
- **Reverse Cull Face**: Some scenes work better when shadow mapping is rendered with face-culling inverted.
5656

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

6060
.. image:: img/shadow_bias.png
6161

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

6464
.. image:: img/shadow_contact.png
6565

6666
Any sort of bias issues can always be fixed by increasing the shadow map resolution,
67-
although that may lead to decreased performance on low-end hardware.
67+
although that may lead to decreased performance.
68+
69+
.. tip::
70+
71+
If shadow biasing is a problem in your scene, the following settings are a good starting point:
72+
73+
- Enable **Reverse Cull Face**. This reduces shadow peter-panning significantly
74+
and prevents lights from exhibiting shadow acne at grazing angles.
75+
The downside is that it may cause lighting to leak in some corners.
76+
- Set **Bias** to ``-0.01``. The bias should be a negative value when
77+
**Reverse Cull Face** is enabled, but it should be a positive value when it's disabled.
78+
- For DirectionalLight, set the directional shadow **Normal Bias** to 0 and **Bias Split Scale** to 1.
79+
You may also want to further decrease **Bias** to a value between
80+
``-0.05`` and ``-0.1` and decrease **Bias Split Scale** depending on your scene.
81+
82+
Following the above tips should make it possible to avoid gaps in shadows without
83+
resorting to contact shadows (which have many issues of their own).
6884
6985
Directional light
7086
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)