Game Development Reference
In-Depth Information
10.3.4 The Clip Matrix: Applying Zoom and
Preparing for Clipping
The second goal of the clip matrix is to scale the x, y, and z components
such that the six clip planes have a trivial form. Points are outside the view
frustum if they satisfy at least one of the inequalities:
Bottom y < −w,
Top
The six planes of the
view frustum in clip
space
y > w,
Left
x < −w,
Right
x > w,
Near
z < −w,
Far
z > w.
So the points inside the view volume satisfy
−w
x
≤ w,
−w
y
≤ w,
−w
z
≤ w.
Any geometry that does not satisfy these equalities must be clipped to the
view frustum. Clipping is discussed in Section 10.10.4.
To stretch things to put the top, left, right, and bottom clip planes in
place, we scale the x and y values by the zoom values of the camera. We
discussed how to compute these values in Section 10.2.4. For the near and
far clip planes, the z-coordinate is biased and scaled such that at the near
clip plane, z/w = −1, and at the far clip plane, z/w = 1.
Let zoom x and zoom y be the horizontal and vertical zoom values, and
let n and f be the distances to the near and far clipping planes. Then
the matrix that scales x, y, and z appropriately, while simultaneously out-
putting the z-coordinate into w, is
2
4 zoom x
3
0
0
0
Clip matrix for
perspective projection
with z = −w at the near
clip plane
0
zoom y
0
0
5
.
(10.6)
f+n
f−n
0
0
1
−2nf
f−n
0
0
0
This clip matrix assumes a coordinate system with z pointing into the
screen (the usual left-handed convention), row vectors on the left, and z
values in the range [−w,w] from the near to far clip plane. This last detail
is yet another place where conventions can vary. Other APIs, (notably,
DirectX) want the projection matrix such that z is in the range [0,w]. In
other words, a point in clip space is outside the clip plane if
Near and far clip planes
in DirectX-style clip
space
near z < 0,
far
z > w.
 
Search WWH ::




Custom Search