Game Development Reference
In-Depth Information
Note that these types of shadows are a quick hack, and although they
enhance the scene, they aren't as realistic as shadow volumes. Shadow
volumes are an advanced concept that we feel is best left out of an
introductory topic. However, it is worth mentioning that the DirectX
SDK has a sample program that demonstrates shadow volumes.
To implement planar shadows, we must first find the shadow that
an object casts to a plane and model it geometrically so that we can ren-
der it. This can easily be done with some 3D math. We then render the
polygons that describe the shadow with a black material at 50% trans-
parency. Rendering the shadow like this can introduce some artifacts,
namely “double blending,” which we explain in a few sections. We
employ the stencil buffer to prevent double blending from occurring.
8.3.1 Parallel Light Shadows
Figure 8.6: The shadow cast with
respect to a parallel light source
Figure 8.6 shows the shadow that an object casts with respect to a par-
allel light source. The light ray from a parallel light, with direction L ,
through any vertex p is given by r ( t )= p + t L . The intersection of the
ray r ( t ) with the plane n p + d = 0 gives s . The set of intersection
points found by shooting r ( t ) through each of the object's vertices with
the plane defines the geometry of the shadow. An intersection point s is
easily found with a ray/plane intersection test:
n
p
t L
d
0
Plugging r ( t ) into the plane equation n p + d =0
n
p
t
n
L
d
t
n
L
d
n
p
Solving for t
d
n
p
t
n
L
Search WWH ::




Custom Search