Game Development Reference
In-Depth Information
Then:
d
n
p
s
p
L
n
L
8.3.2
Point Light Shadows
Figure 8.7: The shadow cast with respect
to a point light source
Figure 8.7 shows the shadow that an object casts with respect to a point
light source whose position is described by the point
L
. The light ray
from a point light through any vertex
p
is given by
r
(
t
)=
p
+
t
(
p
-
L
).
The intersection point 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.
s
can be solved for using the same technique (plane/ray intersection)
used in section 8.3.1.
Note:
Notice that
L
serves different purposes for point and parallel
lights. For point lights we use
L
to define the position of the point light.
For parallel lights we use
L
to define the direction of the parallel light
rays.
8.3.3
The Shadow Matrix
Notice from Figure 8.6 that for a parallel light, the shadow is essentially
a
parallel
projection of the object onto the plane
n
p
+
d
=0inthe
specified light direction. Similarly, Figure 8.7 shows that for a point
light, the shadow is essentially a
perspective
projection of the object
onto the plane
n
p
+
d
= 0 from the viewpoint of the light source.
We can represent the transformation from a vertex
p
to its projec-
tion
s
with the plane
n
p
+
d
= 0 with a matrix. Moreover, we can
represent both an orthogonal projection and a perspective projection
with the same matrix using some ingenuity.
Search WWH ::
Custom Search