Game Development Reference
In-Depth Information
2
4 1
3
5
0
0
0
0
1
0
0
A trivial matrix for
setting w = z, for
perspective projection
.
0
0
1
1
0
0
0
0
Multiplying a vector of the form [x,y,z,1] by this matrix, and then per-
forming the homogeneous division by w, we get
2
4 1
3
0
0
0
5
0
1
0
0
x y z 1
=
x y z z
=⇒
x/z y/z 1
.
0
0
1
1
0
0
0
0
At this point, many readers might very reasonably ask two questions.
The first question might be, “Why is this so complicated? This seems like
a lot of work to accomplish what basically amounts to just dividing by z.”
You're right. In many old school software rasterizers, where the projection
math was hand-coded, w didn't appear anywhere, and there was just an
explicit divide by z. So why do we tolerate all this complication? One
reason for homogeneous coordinates is that they can represent a wider
range of camera specifications naturally. At the end of this section we'll
see how orthographic projections can be handled easily, without the “ if
statement” that was necessary in the old hand-coded systems. But there
are other types of projections that are also useful and are handled naturally
in this framework. For example, the frustum planes do not need to be
symmetric about the viewing direction, which corresponds to the situation
where your view direction does not look through the center of the window.
This is useful, for example, when rendering a very high resolution image
in smaller blocks, or for seamless dynamic splitting and merging of split
screen views. Another advantage of using homogeneous coordinates is that
they make z-clipping (against the near and far clipping planes) identical to
x- and y-clipping. This similarity makes things nice and tidy, but, more
important, on some hardware the vector unit can be exploited to perform
clipping comparison tests in parallel. In general, the use of homogeneous
coordinates and 4 × 4 matrices makes things more compact and general
purpose, and (in some peoples' minds) more elegant. But regardless of
whether the use of 4 × 4 matrices improves the process, it's the way most
APIs want things delivered, so that's the way it works, for better or worse.
The second question a reader might have is, “What happened to d?”
Remember that d is the focal distance, the distance from the projection
plane to the center of projection (the “focal point”). Our discussion of
perspective projection via homogeneous division in Section 6.5 described
Search WWH ::




Custom Search