Game Development Reference
In-Depth Information
Under these DirectX-style conventions, the points inside the view frustum
satisfy the inequality 0 ≤ z ≤ w. A slightly different clip matrix is used in
this case:
Clip matrix for
perspective projection
with z = 0 at the near
clip plane
2
4 zoom x
3
5
0
0
0
0
zoom y
0
0
.
(10.7)
f
f−n
0
0
1
−nf
f−n
0
0
0
We can easily tell that the two matrices in Equations (10.6) and (10.7) are
perspective projection matrices because the right-hand column is [0,0,1,0] T .
(OK, the caption in the margin is a bit of a hint, too.)
What about orthographic projection? The first and second columns of
the projection matrix don't change, and we know the fourth column will
become [0,0,0,1] T . The third column, which controls the output z value,
must change. We start by assuming the first set of conventions for z, that is
the output z value will be scaled such that z/w takes on the values −1 and
+1 at the near and far clip planes, respectively. The matrix that does this is
2
4 zoom x
3
5
Clip matrix for
orthographic projection
with z = −w at the near
clip plane
0
0
0
0
zoom y
0
0
.
2
f−n
0
0
0
f+n
f−n
0
0
1
Alternatively, if we are using a DirectX-style range for the clip space z
values, then the matrix we use is
2
4 zoom x
3
0
0
0
Clip matrix for
orthographic projection
with z = 0 at the near
clip plane
5
0
zoom y
0
0
.
1
f−n
0
0
0
n
n−f
0
0
1
In this topic, we prefer a left-handed convention and row vectors on
the left, and all the projection matrices so far assume those conventions.
However, both of these choices differ from the OpenGL convention, and we
know that many readers may be working in environments that are similar to
OpenGL. Since this can be very confusing, let's repeat these matrices, but
with the right-handed, column-vector OpenGL conventions. We'll only dis-
cuss the [−1,+1] range for clip-space z values, because that's what OpenGL
uses.
It's instructive to consider how to convert these matrices from one set
of conventions to the other. Because OpenGL uses column vectors, the
first thing we need to do is transpose our matrix. Second, the right-handed
conventions have −z pointing into the screen in camera space (“eye space”
in the OpenGL vocabulary), but the clip-space +z axis points into the
Search WWH ::




Custom Search