Cascaded Shadows Maps Tutorial
- Last UpdatedJan 24, 2023
- 3 minute read
1. Choose a screen resolution
Make all the shadows tunings using a screen resolution that is closest to the release resolution. The ratio between the screen resolution and the Shadow map resolution can change the shadows quality.
The following image uses the default parameters for resolution.
Picture 1

2. Choose near/far values
To prevent wasting Shadow map pixels, choose the maximum distance where the pixels are shadowed.
There are two ways to do this:
-
Use the Camera's near/far planes.
-
Set the maximum zfar value with the csm/params/zFarLimit parameter.
In Picture 2, we see that the whole Camera frustum is used for shadows, but only less than half is really needed.
In Picture 3, we have manually set the zfar value a bit too early, or maybe we just do not want pixels that far to have shadows.
Picture 2

Picture 3

3. Setup basic Partitions and Texture resolution
To set up some acceptable partition and texture resolution values, use:
-
csm/params/textureSize = 2048
-
csm/params/numSplits = 2
Notes:
-
2048 is a closer match for this test because the screen resolution was 1920×1080.
-
If using more than two splits, 2048 may have been too much for the area covered by each split. In that case, 1024 would have worked produced good results as well.
Picture 4: 2 partitions, 2048×2048 x 2 Shadow Maps

4. Bias
Remove the Surface acne by using two Bias values:
-
csm/bias/depthBias: Applies some basic Bias to resolve the bigger problems. See Picture 5.
-
csm/bias/slopeScaleDepthBias: Resolve the remaining issues by adding an extra Bias that depends on the slope of the polygons as seen from the Light. See Picture 5.
Then move around the Scene and see if at some positions this Bias is not enough; in that case tweak it.
Picture 5

Picture 6: depthBias = 4000, slopeScaleDepthBias = 0.5
