Shadow Filtering |
This articles explains shadow filtering in DigitalRune Graphics.
This topic contains the following sections:
The resolution of the shadow map (property ShadowPreferredSize) is the most important parameter. This parameter has the biggest influence on quality and performance.
16-bit shadow maps have been sufficient in all test cases. Therefore, the property Prefer16Bit is now set by default.
Without any sort of filtering the shadow shows strong aliasing. Individual shadow map texels are clearly visible in the image above. A pixel is either fully lit or completely in shadow.
Percentage closer filtering (PCF) can be applied to reduce aliasing. Instead of taking a single sample the shadow map is sampled multiple times in a small radius around the original sample position. The results of these shadow tests are averaged, which means that a pixel can be partially shadowed.
Note |
---|
Shadow filtering is applied by the ShadowMaskRenderer (see also Shadow Masks). If you use forward rendering, you have to implement shadow filtering in the forward rendering shader and you are free to implement any filtering method you prefer. |
The property NumberOfSamples determines the quality of the PCF:
We have tried different PCF sample patterns. Jittered PCF samples (using a rotated Poisson disk) seemed to be the most versatile method.
Even without PCF and only one jittered sample ( NumberOfSamples = 1), the look of the shadows improve. Jittered sampling is very useful if the shadows are blurred with a screen space blur (see Shadow Masks).
We use a jitter pattern which is stable in world space. This means the random jitter offset depends on the world space position of the shadowed pixel and not on the screen space position. This reduces shadow flickering from the filter pattern when the camera is moving. The size of the noise pattern is controlled by the property JitterResolution. If JitterResolution is too small, you get large visible dots instead of a fine noise pattern. If it is too large, the shadow edges will be noisy if the camera is too far away.
The property FilterRadius determines the area around the original sample where the additional samples are taken.
The value is specified in texels (of the shadow map). A large filter radius reduces aliasing further and creates a softer, "out of focus" look. – However, a large filter radius creates more shadow acne (see Shadow Acne).