I implemented shadow cascades today. Below is a screenshot of the current shadows, using two cascades. Note the artifacts that I’ve highlighted with green arrows.
About 1/3 of the depth range is represented by the first cascade (and 2/3 in the second cascade). The difference in shadow size between these two cascades is much bigger than expected.
To reduce the artifacts, we can linearly interpolate between the cascades. This article suggests this method (look at figure 9). A region where blending will be done is marked below in light red.
I use a conditional shader branch so that samples from both cascades are only taken in the blend region. This means that reducing the blend region in screen space will reduce computation time. Two ways to reduce the blend region are:
- Reduce the blend region width.
- Increase the cascade split distance from the camera.
Note that increasing the cascade split distance will also reduce the resolution difference between cascades, and therefore make the cascade discontinuity smaller.
Click the above image to enlarge it. The middle green arrow highlights a particularly bad case, where a very long shadow is in the blend region. Increasing the blend region would make the artifact larger, but less noticeable.
Without modifying the cascades, blending between cascades can result in seams at the blend region:
Thankfully though, these seams can be avoided by making the cascades overlap (i.e their depth bounds should overlap with one another).