2.3 Handling resampling errors
2.3.1 Improved reconstruction methods
Percentage closer filtering (PCF) (Reeves et al., 1987) first computes the visibility of samples in the neighborhood of a shadow map query and then filters the results. PCF can handle both resampling aliasing and reconstruction errors by choosing the appropriate size for the resampling neighborhood. To handle resampling aliasing, the neighborhood ideally should correspond to the projection onto the scene of the pixel that generated the query. For aliased regions, this neighborhood will cover a large number of shadow map samples. For regions where reconstruction errors occur, however, the neighborhood will be smaller than that of a single shadow map texel. Filtering with such a small neighborhood would offer no improve- ment. Thus the size of the neighborhood should be clamped to some minimum extent larger than 1 texel. Using a large neighborhood blurs the jagged shadow edges. This effect resembles the penumbra of a soft shadow and can be visually pleasing. It is not a true penumbra, how- ever, because its width does not change with distance from the occluder. The more samples that are used for PCF, the smoother the edges become. Hardware implementations of PCF on current GPUs use bilinear interpolation instead of stochastic sampling. This produces a smooth transition from shadowed to unshadowed regions but preserves some blockiness along
the shadow edge. Figure 2.2 shows both the native hardware PCF and stochastic PCF applied using a fragment program.
Silhouette shadow maps (Sen et al., 2003) reconstruct a hard edge by augmenting the shadow map with extra information about the location of the silhouette edges of shadow casters. The silhouette edges are rendered into the shadow map storing at each texel the coordinates of a single point along the edge that falls within the texel. The point coordinates in the neighborhood of a shadow map query are used to reconstruct the silhouette edges. Depth information is used to determine whether the query lies on the shadowed or unshadowed side of the reconstructed edges. Only one point is stored per texel, so errors can occur when multiple edges fall within the same texel.
Variance shadow maps (Donnelly & Lauritzen, 2006) store an approximation of the distri- bution of depth values within a texel. These values can be filtered with standard techniques. The technique computes the exact result of performing PCF for a planar occluder parallel to a planar receiver. For other configurations, it gives only an upper bound on the fraction of the filtered region that is unoccluded, but it often works well in practice. However, when the variance in depth is high, the technique can cause light to leak into the shadows causing strange artifacts.
Convolution shadow maps (Annen et al., 2007) store an approximation of the visibility function instead of depth values. The visibility function generated by the depth comparison can be represented as a Heaviside step function. This function is expanded in terms of the Fourier basis functions. The advantage of this representation is that the nonlinear depth comparison can be “linearized” so that the shadow map can be prefiltered. A convolution shadow map is constructed by using a normal shadow map to generate a number of basis images. Prefiltering can be applied to visibility function simply by prefiltering the basis images. One disadvantage of this algorithm is that a large number of basis images may be required to obtain hard edges.
Scherzer et al. (2007) reuse the shadowing information from previous frames to provide both temporal smoothing and more accurate reconstruction of shadow edges. A history buffer stores for each pixel in the image a weighted average of the shadow map query results for
previous frames, as well as the eye space depth of the fragment of the last frame. The history buffer is updated each frame using a weighted combination of the buffer’s previous value and the query results computed from the shadow map for the current frame. The updated history buffer is then used to render the shadows. The weights for query results are computed independently for each pixel. Each fragment is transformed back into the eye space of the previous frame and its depth is compared to that stored in the history buffer. If the depth is not within a user specified tolerance, then the previous history is assigned a weight of 0 and the query result for the current frame is assigned a weight of 1. This is necessary to properly handle disocclusions. Otherwise, a weight is computed using the confidence of the current query result. The confidence is based on the distance of the query location from the center of the corresponding texel in the shadow map. Query locations far from the center are assigned low confidence as the results of these queries is less likely to be accurate and should have less influence on the history buffer. Jittering the shadow map every frame ensures that over time, high confidence query results appear, which causes the history buffer to converge to the exact shadow edge. However, the algorithm may not converge for moving shadows caused by moving objects or a moving light source, leading to overly smoothed or smeared shadows.