Perspective Projection

Perspective projections are used to produce images which look natural. When we view scenes in everyday life far away items appear small relative to nearer items.

A side effect of perspective projection is that parallel lines appear to converge on a vanishing point.

An important feature of perspective projections is that it preserves straight lines, this allows us to project only the end-points of 3D lines and then draw a 2D line between the projected endpoints.

Video tutorial on perpective projection.

Objects in the real world appear smaller as they move further away.

Perspective projection depends on the relative position of the eye and the viewplane. In the usual arrangement the eye lies on the z-axis and the viewplane is the $xy$ plane. To determine the projection of a 3D point connect the point and the eye by a straight line, where the line intersects the viewplane. This intersection point is the projected point.

Perspective v's Parallel Projection
Perspective Projection
Medieval paintings do not attempt to render perspective correctly
pre-renaissance often show poor understanding of perspective
Giotto was the first painter to systermatically attempt to achieve perspective in his paintings.
Perspective projection in the 16th century
Raphael's "The School of Athens" shows architectural perspecive to good effect
Byzantine art used reverse perspective, where the vanishing points are outside the image
Post-renaissance artisits such as Canaletto perfected perspective technique
Hogarth has fun with 'false' perspective

Building a perspective projection transformation

Projecting a point using perpective projection involves finding where the line from the eye to the point intersects the viewplane. This can be calculated using similar triangles (see diagram below)

calculate projection using similar triangles

Assume the eye is at the origin and the viewplane is $d$ on the n-axis, the projected point $p'$ can be found using similar triangles

Note; the n-coordinate of the point is usually negative, so the distance from the eye to the point is $p_n$
\[\begin{eqnarray*} \frac{p'_v}{d}&=&\frac{p_v}{p_n} \\ v'&=&d\frac{p_v}{-p_n}\\ \textrm{similarly for $p'_u$}\\ p'_u&=&d\frac{p_u}{-p_n}\\ \textrm{and we know that;}\\ p'_n&=&d \end{eqnarray*}\]

So the point $\vec{p}(p_u,p_v,p_n)$ is projected to $\vec{p'}(d\frac{p_u}{-p_n},d\frac{p_v}{-p_n},d)$. Typically, the near clipping plane will be used as the view plane, so replacing $d$ with $n$ (for "near")the point is projected to $\vec{p'}(n\frac{p_u}{-p_n},n\frac{p_v}{-p_n},n)$This transformation can be performed by multiplying the following homogenous matrix;

\[ \mathbf{\hat{M}}=\left(\begin{array}{ccccc} n&0&0&0\\ 0&n&0&0\\ 0&0&n&0\\ 0&0&-1&0 \end{array} \right) \] \[\begin{eqnarray*} \mathbf{\hat{M}}\vec{p}=\left(\begin{array}{ccccc} np_u\\np_v\\np_n\\-p_n \end{array}\right) \end{eqnarray*}\]

To convert this homogenous point to an 'ordinary' point, we need to divide through by the fourth component and discard. This step is called perspective division.

\[\begin{eqnarray*} \left(n\frac{p_u}{-p_n},n\frac{p_v}{-p_n},n\right) \end{eqnarray*}\]

Pseudo-depth

The perspective projection above discards information about vertex depth (all projected vertices have a depth of $d$). Without the relative depth information we will be unable to remove hidden surfaces later.

Retaining $p_n$ seems like the simplest way of keeping the depth information, however it turns out to be easier and neater to use the following fuction for the depth;

\[\begin{eqnarray*} p'_n=\frac{ap_n+b}{-p_n}\\ \textrm{where}\\ a=-\frac{f+n}{f-n}\\ b=\frac{-2fn}{f-n} \end{eqnarray*}\]

This form is known as the pseudodepth and has two advantages;

  1. It can easily be incorporated into the projection matrix
  2. points on the near plane will be given a depth of $-1$ and points on the far plane will be at $+1$

This modifcation can be incorporated into the perspective projection matrix;

\[ \mathbf{\hat{M}}=\left(\begin{array}{ccccc} d&0&0&0\\ 0&d&0&0\\ 0&0&a&b\\ 0&0&-1&0 \end{array} \right) \]

 

Effect on view volume of perspective transformation

For perspective projection, the view volume is shaped like a pyramid, in fact the shape is a truncated pyramid, sometimes called the view frustum, because the top is chopped off by the near clipping plane.

The near and far clipping planes are optional, but without them the view volume would extend ito infinty in both directions.

The perspective transformation alters a 3D to another 3D point, in order to "prepare" the point for projection. As all the ponts in the view volume are transformed to a new position, it is useful to think of this transformation "warping" 3D space and changing the shape of the view volume. This warping preserves the following features

  1. straightnes
  2. flatness
  3. inbetween-ness
  4. lines perpendicular to the z-axis remain perpendicular
  5. lines through the eye become lines parallel to the z-axis

What shape will the vew volume have after this warping?

 

The near plane is transformed to the plane $z=-1$, the backplane is transformed to $z=+1$, the top and bottom of the view volume are transformed to planes parallel to the $uz$plane and the left and right sides are trandformed to planes parallel to the $vz$plane. So the view volume is transformed to a parallelpiped (kind of a cuboid). This will make the later operation of clipping much simpler.

This warping also chages the shapes of objects being projected so that when viewed from an orthographic projection they appear to have "perspective". Basically, features further away from the the eye are transformed to be smaller.

Canonical View Volume

To make clipping efficient, we would like to modify the shape of the transformed view volume so it is independent of camera properties. It will be shifted and scaled so that it lies between -1 and 1 in each dimension. This will be known as the canonical view volume. The process used is the similar as the Normalization process for the orthographic projection. The normalization requires a translation to centre the view volume on the origin and to scale it so that the height and width are 2 (note the depth has already been scaled by the pseudo-depth). A matrix to do this is;

\[ \mathbf{\hat{N}}= \left(\begin{array}{ccccc} \frac{2}{w_r-w_l}&0&0&-\frac{w_r+w_l}{w_r-w_l} \\ 0&\frac{2}{w_t-w_b}&0&-\frac{w_t+w_b}{w_t-w_b} \\ 0&0&1&0 \\ 0&0&0& 1 \end{array} \right) \]

Multiplying this normalization matrix by the persprective transformation matrix gives us the perspective projection matrix;

\[ \mathbf{\hat{P}}=\mathbf{\hat{N}} \mathbf{\hat{M}}= \left(\begin{array}{ccccc} \frac{2n}{w_r-w_l}&0&\frac{w_r+w_l}{w_r-w_l}&0 \\ 0&\frac{2n}{w_t-w_b}&\frac{w_t+w_b}{w_t-w_b}&0 \\ 0&0&-\frac{f+n}{f-n}&\frac{-2fn}{f-n} \\ 0&0&-1& 0 \end{array} \right) \]