Game Development Reference
In-Depth Information
If d δ
, then the
light source lies behind the near plane; otherwise, the light source lies in the near
plane.
In the case that the light source lies in the near plane, the near-clip volume is
defined by the planes
>
, then the light source lies in front of the near plane; if d δ
<−
K . These two planes are
coincident but have opposite normal directions. This encloses a degenerate near-
clip volume, so testing whether an object is outside the volume amounts to de-
termining whether the object intersects the near plane.
If the light source does not lie in the near plane, we need to calculate the ver-
tices of the near rectangle. In eye space, the points R ,
=
0, 0,
1,
n
and
=
0, 0,1, n
K
0
1
R ,
R , and R at the four
corners of the near rectangle are given by
R
R
R
R
=
neane
,
,
n
0
=−
neane
,
,
n
1
=−
ne
,
ane
,
n
2
=
ne
,
ane
,
n
,
(10.17)
3
where n is the distance from the camera to the near plane; a is the aspect ratio of
the viewport, equal to its height divided by its width; and e is the camera's focal
length, related to the horizontal field-of-view angle α by Equation (5.27). These
four points are ordered counterclockwise from the camera's perspective. For a
light source lying in front of the near plane, the world-space normal directions
N , where 0
≤≤
i
3
, are given by the cross products
(
)
(
R ,
)
(10.18)
N
=−
RR
×
LLL
,
,
L
(
)
i
i
i
1mod4
x
y
z
w
i
where each
R is the world-space vertex of the near rectangle given by
i
=
RWR . For a light source lying behind the near plane, the normal directions
are simply the negation of those given by Equation (10.18). The corresponding
world-space planes
i
i
K bounding the near-clip volume are given by
1
()()()
K
=
NNN NR
,
,
,
.
(10.19)
i
i
x
i
y
i
z
i
i
N
i
We close the near-clip volume by adding a fifth plane that is coincident with the
near plane and has a normal pointing toward the light source. For a light source
lying in front on the near plane, the fifth plane K is given by
(
)
1T
K
=
W
0, 0,
1,
n
,
(10.20)
4