Game Development Reference
In-Depth Information
In the case that an infinite view frustum is being used, the far plane is ig-
nored, and the edges that would lie between the far plane and any of the four side
planes never participate in the construction of a new plane. The shadow-casting
region is infinitely large in this case, but it is still convex and properly bounded.
Once the bounding planes of the shadow-casting region have been deter-
mined, we test for object intersection just as we would for the ordinary view frus-
tum. For each plane, we check to see whether the object lies completely on the
negative side of any plane, and if it does, then it is rejected as a potential shadow
10.2 Shadow Mapping
The technique known as shadow mapping is so named because a scene is ren-
dered from the perspective of a light source to generate a special shadow map
that is subsequently used in the ordinary rendering pass from the camera's per-
spective. Instead of three-component color, each pixel in the shadow map holds a
single number representing the depth of the associated point in the scene with
respect to the light source, as shown in Figure 10.2. Since it is an image-based
technique, shadow mapping can be used to generate shadows for objects that use
the alpha test to cut holes in their surfaces, as is often done for things like the
leaves on a tree. Using the stencil shadow technique for these kinds of objects is
10.2.1 Rendering the Shadow Map
In order to render a shadow map, we first determine the region of space in which
shadow castors may be positioned, as described in the previous section. We then
create a bounding box for that region that is aligned to the light source's coordi-
nate axes, as shown in Figure 10.3. The z axis points in the opposite direction that
the light is shining, and the x and y axes represent the horizontal and vertical di-
rections in the shadow map. Shadow mapping is most easily implemented for an
infinite light or spot light because each has a specific lighting direction. Shadow
mapping for point lights is more difficult, but recent advancements in graphics
hardware has made this more practical. 1
After the aligned bounding box has been determined, we position the camera
at the light source's location, point it in the direction of the light, and set up an
1 For instance, complete cube shadow maps can be rendered in a single pass using ge-
ometry shaders, and depth-based cube maps are supported in OpenGL 3.0 and later.
Search Nedrilad ::

Custom Search