

Perspective aliasing, a common artifact, is shown in Figure 5. The types of artifacts that can occur are summarized next. The shadow depth map algorithm is the most widely used real-time shadowing algorithm, but still produces several artifacts requiring mitigation. The depth test can now be performed by indexing the depth buffer from the first pass with the X and Y texture coordinates and comparing the resulting depth value against the Z-texture coordinate.įigure 4. Everything needed to perform the depth test is now in this texture coordinate. The pixel shader receives the interpolated position and the interpolated texture coordinates. It's a transformation that scales and translates the points from view space (–1 to 1 in X and Y) to texture space (0 to 1 in X and 1 to 0 in Y). The view-projection-texture matrix is the same matrix used to render the scene in pass 1 with one additional transform. Each vertex is also transformed by the light's view-projection-texture matrix and passed to the pixel shader as a texture coordinate. Each vertex is transformed into the camera's view space and passed to the pixel shader as the position.

In the second pass (Figure 4), the vertex shader transforms each vertex twice. This now can be used in pass 2 to determine which pixels are occluded from the light.įigure 3. The end result of this first pass is a depth buffer containing the scene's depth information from the point of view of the light. More specifically, the vertex shader transforms the geometry into light-view space. In the first pass (Figure 3), the geometry is rendered into a depth buffer from the point of view of the light. In the second pass, this map is used to compare each pixel's depth in light space against its corresponding depth in the light space depth map. The first pass generates a depth map in light space. The shadow depth map algorithm is a two-pass algorithm. Shadows with severe artifacts (left), and shadows after implementing the techniques described in this article (right) The techniques explained in this article are implemented in the sample CascadedShadowMaps11 in the DirectX SDK.įigure 1. Correctly implementing these techniques drastically improves standard shadows. When shadow map shortcomings are addressed, the difference in quality can be impressive (Figure 1). Selecting the correct techniques to mitigate specific artifacts is nontrivial.
AC3D NEAR SNAP PIXELS HOW TO
This technical article is written for the intermediate graphics developer who has implemented shadows, but does not fully understand why specific artifacts appear and is not sure how to work around them. Adding basic shadow maps to a title typically is straightforward, but understanding the nuances of shadow artifacts can be challenging. This technical article provides an overview of some common shadow depth map algorithms and common artifacts, and explains several techniques-ranging in difficulty from basic to intermediate-that can be used to increase the quality of standard shadow maps. Three decades later, despite advances in hardware and software, shadowing artifacts-namely shimmering edges, perspective aliasing, and other precision issues-persist. Shadow maps, first introduced in 1978, are a common technique for adding shadows to games.
