Game Development Reference
In-Depth Information
and this is necessary for perspective-correct interpolation of vertex attributes.
Thus, we are left with no choice but to replace the third row of the projection ma-
trix with
=−
CM .
(5.62)
M
3
4
After making the replacement shown in Equation (5.62), the far plane F of
the view frustum becomes
=−
=
MM
MC .
F
4
3
2
(5.63)
4
This fact presents a significant problem for perspective projections because the
near plane and far plane are no longer parallel if either C or C is nonzero. This
is extremely unintuitive and results in a view frustum having a very undesirable
shape. By observing that any point
P
=
x yw
,,0,
for which
C P
⋅=
0
implies that
we also have
F P , we can conclude that the intersection of the near and far
planes occurs in the x - y plane, as shown in Figure 5.22(a).
Since the maximum projected depth of a point is achieved at the far plane,
projected depth no longer represents the distance along the z axis, but rather a
value corresponding to the position between the new near and far planes. This
has a severe impact on depth-buffer precision along different directions in the
view frustum. Fortunately, we have a recourse for minimizing this effect, and it is
to make the angle between the near and far planes as small as possible. The plane
C possesses an implicit scale factor that we have not yet restricted in any way.
Changing the scale of C causes the orientation of the far plane F to change, so we
need to calculate the appropriate scale that minimizes the angle between C and F
without clipping any part of the original view frustum, as shown in Figure
5.22(b).
⋅=
0
(
)
=
1T
C MC be the projection of the new near plane into clip space (us-
ing the original projection matrix M ). The corner
Let
Q of the view frustum lying
opposite the plane
C is given by
() ()
=
sgn
C
,sgn
C
,1,1
.
(5.64)
Q
x
y
(For most perspective projections, it is safe to assume that the signs of
and
C
C
x
y
are the same as C and C , so the projection of C into clip space can be avoided.)
Once we have determined the components of
Q , we obtain its camera-space
1
counterpart Q by computing
Q
=
M
Q . For a standard view frustum, Q coin-