|
The shadows provide very important visual clues that
can be used to enhance realism of rendered scenes. Without
them scenes look flat, which makes it difficult to determine
spatial relationship between objects in the scene. There're
two most frequently used methods for generating shadows
in real-time rendering -- shadow volumes and shadow
mapping. The later uses depth maps rendered from the
light position to find out is object or its part is
in shadow or not.
The ShadowMap sample demonstrates the use of 1.4 pixel
shaders to render antialiased shadows using depth shadow
maps. The shadow antialiasing is achieved by implementing
custom filtering technique in the pixel shader.
The ShadowMap sample renders scene depth from the light
source position into a texture and later uses this texture
with depth information to compute shadow visibility
query. One of the problems of such approach is a lack
of high-precision renderable texture formats that results
in poor shadow quality. The sample solves this problem
by packing depth values into multiple channels of the
depth texture, raising the depth resolution from 8-bit
to 11-bit. A look-up texture is used to perform such
conversion. The fact that Radeon 8500 and newer cards
supporting 1.4 pixel shaders have higher than 8-bit
precision in the shader pipe allow us to make this trick
work.
Another pixel shader is used to render scene with shadows
by sampling shadow maps and performing shadow visibility
test on a per-pixel basis. The shader unpacks multi-channel
depth information into a single depth value and uses
it for depth testing. To antialias shadows four samples
are processed in the pixel shader with a special filter.
The percentage closer filtering is used as described
in Rendering Antialiased Shadows with Depth Maps paper
by William T. Reeves, David H. Salesin and Robert L.
Cook. The texture coordinates for all four samples are
computed in the vertex shader using four different transformation
matrices setup by the application.
For the reference the sample visualizes the shadow
map in a small overlay displayed in the top-left corner
of the window.
|