William D. Shoaff with lots of help
The view-to-perspective map transforms a region in view space
defined by a field of view angle
,
near, and far planes
into the truncated pyramid (frustum)
After a divide by the homogeneous coordinate w,
we know that points inside the viewing frustum will satisfy
Now clip space is chosen to make clipping algorithms as simple and
efficient as possible.
Jim Blinn [1] recommends using the region
This matrix is composed with the view-to-perspective map to bring us
directly from view space into clipping space; no stopping in perspective
space
How does this work with values used for the variables? Some find answers to this type of questions useful; I find it an opportunity for arithmetic errors, but here goes anyway.
Let's pretend that our field of view is defined by
,
the near plane is given as zn=4,
the far plane by zf=12, and the viewport we ultimately want
to display upon has aspect ratio a=0.75 (the old TV standard).
We can plug these values into the matrix
Now we could run some view points through this transform and use our intuition to conclude it is correct (or incorrect), but it might be more insightful to run lines through the transformation to see how they are mapped.
| Line | Description |
|---|---|
|
|
A line from eye through view frustum center |
|
|
A line from eye through upper-right frustum corner |
|
|
A line from eye through lower-left of frustum |
The map is two steps: (1) run the points through the matrix; (2) perform a homogeneous divide.
Also note when z=4 and z=12 we're on the front and back faces of the clipping cube, respectively.
Let's summarize where we are:
First we map objects from model space to view space by composing
modeling transforms that place objects in the world
with the view transform that presents the world as seen from
a virtual camera (our cyclops eye point).
In view space we perform illumination and maybe some hidden surface analysis.
From view space we map into clip space using the transformation constructed
above.
Clip space is chosen to make the clipping algorithm we may use (there are
many of them) as efficient as possible.
Following Blinn [1]
We have chosen to use
,
,
as the clipping cube.
To construct the map correctly we need to have a prevision of the
shape of the viewport where the scene will be displayed.
That is, we need to know the aspect ratio
of the display window.
Another fact we noted was that points in the eye-plane can not be projected (we'll get a divide by zero error). A corollary of this is that objects behind the eye-plane will be inverted upon projection.