i
i
i
i
i
i
i
i
4.3. Computing Viewing Rays 73
looking views using perspective projection: we simply project along lines that
pass through a single point, the viewpoint, rather than along parallel lines (Fig-
ure 4.4). In this way objects farther from the viewpoint naturally become smaller
when they are projected. A perspective view is determined by the choice of view-
point (rather than projection direction) and image plane. As with parallel views
there are oblique and non-obliqueperspective views; the distinction is made based
on the projection direction at the center of the image.
You may have learned about the artistic conventions of three-point perspec-
tive, a system for manually constructing perspective views (Figure 4.5). A sur-
prising fact about perspective is that all the rules of perspective drawing will be
followed automatically if we follow the simple mathematical rule underlying per-
spective: objects are projected directly toward the eye, and they are drawn where
they meet a view plane in front of the eye.
4.3 Computing Viewing Rays
From the previous section, the basic tools of ray generation are the viewpoint (or
view direction, for parallel views) and the image plane. There are many ways to
work out the details of camera geometry; in this section we explain one based
on orthonormal bases that supports normal and oblique parallel and orthographic
views.
In order to generate rays, we first need a mathematical representation for a ray.
A ray is really just an origin point and a propagation direction; a 3D parametric
line is ideal for this. As discussed in Section 2.5.7, the 3D parametric line from
the eye e to a point s on the image plane (Figure 4.6) is given by
Figure 4.6. The ray from
the eye to a point on the im-
age plane.
p(t)=e + t(s − e).
This should be interpreted as, “we advance from e along the vector (s − e) a
fractional distance t to find the point p.” So given t, we can determine a point p.
The point e is the ray’s origin,ands − e is the ray’s direction.
Caution: we are overload-
ing the variable
t
,whichis
the ray parameter and also
the
v
-coordinate of the top
edge of the image.
Note that p(0) = e,andp(1) = s, and more generally, if 0 <t
1
<t
2
,then
p(t
1
) is closer to the eye than p(t
2
). Also, if t<0,thenp(t) is “behind” the eye.
These facts will be useful when we search for the closest object hit by the ray that
is not behind the eye.
To compute a viewing ray, we need to know e (which is given) and s. Finding
s may seem difficult, but it is actually straightforward if we look at the problem
in the right coordinate system.