Game Development Reference
In-Depth Information
to allow in only light that passes through a single point. However, in the
mathematical universe inside a computer, it works just fine.
As expected, moving the plane of projection in front of the center of
projection removes the annoying minus signs:
Projecting a point onto
the plane z = d
x
y
z
p
=
=
dx/z dy/z d
.
(6.12)
6.5.2 Perspective Projection Matrices
Because the conversion from 4D to 3D space implies a division, we can
encode a perspective projection in a 4 × 4 matrix. The basic idea is to
come up with an equation for p
with a common denominator for x, y, and
z, and then set up a 4 × 4 matrix that will set w equal to this denominator.
We assume that the original points have w = 1.
First, we manipulate Equation (6.12) to have a common denominator:
x y z
p
=
dx/z dy/z d
=
dx/z dy/z dz/z
=
.
z/d
To divide by this denominator, we put the denominator into w, so the 4D
point will be of the form
x y z z/d
.
So we need a 4 × 4 matrix that multiplies a homogeneous vector [x,y,z,1]
to produce [x,y,z,z/d]. The matrix that does this is
2
4 1
3
0
0
0
Projecting onto the
plane z = d using a 4 × 4
matrix
5
0
1
0
0
x y z 1
=
x y z z/d
.
0
0
1
1/d
0
0
0
0
Thus, we have derived a 4 × 4 projection matrix.
There are several important points to be made here:
Multiplication by this matrix doesn't actually perform the perspective
transform, it just computes the proper denominator into w. Remem-
ber that the perspective division actually occurs when we convert
from 4D to 3D by dividing by w.
There are many variations. For example, we can place the plane of
projection at z = 0, and the center of projection at [0,0,−d]. This
results in a slightly different equation.
This seems overly complicated. It seems like it would be simpler
to just divide by z, rather than bothering with matrices. So why is
Search WWH ::




Custom Search