This topic contains the following sections:
Shadow acne is another problem caused by the limited resolution of the shadow map.
First, a scene with no shadow acne:
When shadows are rendered naively – simply comparing a depth value with the value in the shadow map – the following happens: Faces are likely to be self-shadowed. This erroneous self-shadowing is called shadow acne.
Note that increasing the resolution of the shadow map does not prevent shadow acne…
… nor does shadow map filtering. A large filter radius can make the problem even worse.
To avoid shadow acne, the pixels in the scene need to be moved closer to the light source during the shadow test. This is called biasing. Different biasing methods exist:
A bias can be applied to the depth values when rendering the shadow map or when reading the shadow map: The depth bias and the slope-scaled depth bias are usually applied when the shadow map is created using the depth bias features of the graphics hardware. The other bias types are applied when the shadow map is read.
We have tested these methods and found a combination of depth bias and slope-scaled normal offset to be the most robust. Both are applied when the shadow map is read. The bias values are controlled with the shadow properties DepthBias and NormalOffset.
Increasing the DepthBias moves lit pixels closer to the light (the pixels are only moved during the shadow test, not in the real scene). The depth bias removes shadow acne from surfaces facing the light source.
As shown in the image above, faces parallel to the light direction may still show shadow acne. To clean these faces the NormalOffset needs to be increased. The normal offset virtually pushes pixels into the light by moving them in the direction of the surface normal.
Depth bias and normal offset values are specified in shadow map texels. For example, depth bias = 3 means that the pixels is moved the length of 3 shadows map texels closer to the light.
This unit choice makes bias settings easier to understand and to configure: When shadow filtering is disabled, the size of the shadow map texels is easy to spot in the stair pattern of the shadow edges.
This unit ensures that the bias automatically scales with the shadow map resolution. The same bias settings work regardless of the shadow map resolution.
The bias also scales for lights with perspective projections such as spotlights: Objects near a spotlight (good shadow map resolution) only need a small bias, objects in the distance (poor shadow map resolution) need a large bias. By keeping the bias proportional to the projected shadow map texels, the same settings work at all distances.
If shadow filtering uses a large filter radius, you need larger depth bias and normal offset values. However, using large values can introduce a new problem called Peter Panning, where the shadow becomes disconnected from the shadow caster.
Therefore, make the depth bias and normal offset only as large as necessary to remove shadow acne.