CS 184: COMPUTER GRAPHICS


PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

Lecture #20 -- Wed 4/6/2011.






   

How (by what geometrical construction)
can you find the exact location in the
image plane of the vanishing point of
a given set of parallel lines or edges ?

What is the maximal / minimal number of vanishing points that can result from a perspective projection onto the image plane of the above hexagonal prism (depending on its orientation with respect to the imaging plane) ?


The Classical Rendering Pipeline (cont.)  -- Perspective!

Vanishing Points and Vanishing Lines  (the hallmark of perspective!)

The vanishing point is the perspective image of the point where a bundle of parallel lines seem to converge. (Example: Road)
We can find this point by shooting a ray in the direction of the parallel bundle and finding its intercept with the imaging plane.
Ray bundles parallel to the imaging plane do not have vanishing points!

If you have multiple bundles of parallel lines in the same plane,
then all their vanishing points form a vanishing line (or a "horizon") -- example: "2-runway airfield".
Vanishing line = "horizon" of a plane = collection of the vanishing points of all the lines in the plane.
Parallel planes have the same vanishing line.
To find their vanishing line, pick the one parallel plane through the eye point and find its intersection with the imaging plane.

N-Point Perspectives

Art schools make a big fuss about drawing worlds with 1-, 2-, or 3-point perspectives,
showing the corresponding number of vanishing points for bundles of parallel lines.
However, this really only makes sense for "brick worlds" with three sets of dominant directions.
In worlds with more than 3 major directions for which we find many parallel edges,
each such bundle of parallel lines can produce its own vanishing point.
The only situation when such a bundle does not produce a vanishing point is when it lies parallel to the imaging plane.

Thus an octahedron with 6 pairs of parallel edges can have 6 vanishing points, and can thus be rendered in "6-point perspective" !
What is the minimum number of vanishing points that it can produce ?
-- Well, it can be oriented in such a way that one of its triangular faces lies parallel to the imaging screen;
then 3 parallel bundles do not have a vanishing point, and there remain only three.

Similarly, an icosahedron (20 triangles) with 15 pairs of parallel edges can have a maximum number of 15 vanishing points and a minimum number of 10. (5 edges lie in the same plane at the base of a five-sided pyramid and they can thus all be simultaneously parallel to the image plane and loose their vanishing points.)
What are the maximum and minimum number for a dodecahedron  (12 pentagons, 15 edge pairs)?
-- or
for a  n-sided regular prism  (2 n-gons plus n rectangular faces)?  

Overview and Classifications of Projections

Parallel Projections
   Orthographic (plan-view, elevation, isometric): The direction of projection (dop) is parallel to the n-axis of the VRCS.
   Oblique ("cabinet", "cavalier" projections): The direction of projection (DOP) is skewed with respect to the n-axis of the VRCS;
   different amounts of foreshortening of the 3rd dimension are being used (most often: 1.0, or 0.5).
Perspective Projections
    Eye (COP) at a finite distance from object to be imaged.
    "N-point perspectives" (N=1, 2, 3 ...)

The unified camera model (see last lecture) can handle all of them.

Polygon Clipping and Perspective

Polygons (triangles) are the basic primitives that we are rendering.
We need to clip them around the (display) window edges, so that we don't send invalid addresses to the display bit-planes.
But we also want to clip against an additional front- and back-clipping plane, so that we can cull away a lot of visual clutter in the scene.
There are also some new potential problems that make clipping really essential (and we can't even defer it to the very end, and just do it in 2D !)
Perspective images of line segments, and the need for near-plane clipping:
Study the various cases where the endpoints of a line segment may lie:
1.) Both in front of the eye: ==> OK
2.) Both behind the eye: ==> No problem; but do we want to see this ?
3.) One in front, one behind: ==> Problems! Image goes through infinity! Clipping is crucial!
On the other hand you can see the point at infinity of the original line: This is the "Vanishing Point"

Various Clipping Options:

1.) Do it first just in z, to avoid above wrap-around problem, and then do more clipping later in 2D;
     This is conceptually plausible, but inelegant, since it involves two different clipping steps.
2.) Do it in 3D on the canonical view frustum;
     This is doable, but it involves more complex arithmetic expressions for the sides of the frustum.
3.) Do it in 4D in the normalized frustum  in the space of the homogeneous coordinates;
     This is the most elegant solution, it avoids unnecessary expensive coordinate divisions by w,
      and the clipping calculations involve very simple numerical values.
     (You don't need to know the detailed math, just the costs and benefits of doing it in 4D)

The Complete (Perspective) Viewing Transformation : from this  to this (Shirley)!

Rather than doing a real projection -- and thereby loosing the depth (ordering) information, we perform a 3D to 3D transformation
of the piece of the World that we are interested in into a canonical view volume where it is easy to do culling and clipping.

1.)  First we perform a shear operation (if necessary) to bring the center of the window n the n = -1 plane
      (which specifies the opening of the view frustum) onto the n-axis.

2.)  Then we perform a non-uniform scaling in all three axes so that the half-angles of the view frustum 
       in the x- and y-directions are set at 45 degrees, and so that the back clipping plane is brought to n =
-1.
3.)  This is all very similar to the case of parallel projection; but now comes the really nifty step:
The Perspective Transformation: (just the orthogonalization of the view frustum)
This is a clever 3D to 3D transformation (using homogeneous coordinates) that distorts the u and v dimensions in just the right way,
so as to achieve a proper perspective look, when we finally perform a parallel projection along the n-axis.
It also maintains all relative orderings in the n-direction, so that we can do hidden surface elimination later.

Furthermore, it keeps the back clipping plane (B) at the n=-1 plane, and it moves the front clipping plane (F) to the n=0 plane.

[ Shirley takes an intermediate step and keeps (B) and (F) in the same place; this yields a simpler "perspective matrix" Mp ]

Now we have the whole view volume mapped into the same canonical half-brick as in the case of a parallel projection.
In general, it maps the point {x, y, z, 1} into {x, y, (z
- zmin)/(1 + zmin), -z} .
It also maps the eye to infinity.
Furthermore, rays through the eye become parallel; and bundles of parallel lines converge in their Vanishing Point.
This is some kind of cyclic permutation of all the important points of interest!

Finally: The Actual Projection to 2D:
Once we have transformed everything of interest into the canonical half-cube, doing the projection to 2D is trivial:
Just set the z-coordinate to zero !

Mathematics of Planar Geometric Projections

How do the coordinates coming from an original object get changed during the projection step ?
Rather than just carying out projections, we do a full 3D->3D transformation that produces the same effect on the x- and y- coordinate values but also preserves the relative ordering of the geometry in the z-direction.

NOTE:  Different books use different formalisms and even different canonical viewing volumes.
In 1996 Jim Blinn suggested to use a full (double) unit cube for the canonical viewing volume (twice the half-brick used above).
Some of the textbooks followed his advice and some didn't.
Shirley does use the full canonical cube going from +1 to -1 in z.

The math for that case is very well described in Chapter 7.  Read it carefully.

In particular, Shirley, derives a simple perspective matrix, Mp, that takes a symmetrical view frustum and orthogonalizes it into
a "brick" with the same front face and the same back plane but shrunk back face; this brick is subsequently mapped to the canonical (full) brick.
Shirley breaks the whole perspective transformation into three easy to understand steps:
1.)  The view transformation that standardizes arbitrary camera positions and gaze directions into the origin and down the z-axis;
2.)  The perspective matrix that un-warps the view frustum into a rectilinear brick (as one would get in a parallel projection);
3.)  The mapping to the canonical view volume (a full cube with planes at +/-1) for easy clipping and depth comparisons ...
Together they formt he perspective projection matrix.
It can just as easily be mapped into the traditional half-cube using the same perspective matrix.
Review Chapter 7 again and learn how to use these matrices !

The key concepts are exactly the same in both cases, but the resulting perspective transformation matrix is somewhat different.
You can also find the gory detailed math for the canonical half-cube version here:
Camera Specifications and Mapping of the Viewing Volume into the Canonical Half-Cube.


The Course Project

CS 184 is now officially a DESIGN-Course!
ABET requirements specify, that such courses:
-- have a  DESIGN-Project  and
-- teach and test  Technical Communication Skills.

DESIGN-Project  must have
-- some clear task or goal,
-- some constraints or specifications,
-- some trade-offs between different possible solutions.
For instance:
Design a walking creature with 5 legs that can walk across a uneven (fractal) landscape...
or:
Model the reflections and refractions in a polyhedral glass container filled (partially) with water...
==> Start thinking about such task that fit into the scope of what you have learned in CS 184.

I plan to fulfill the 
Technical Communication Skills  requirement
by having you give a short (5-minute), formal, oral presentation before you demonstrate your projects.
This oral part will count for 25% of your project grade.
It is an important skill to be able to present your ideas and accomplishments to your peers and future bosses.
==> We will talk more about this in future lectures.


Reading Assignments:

Shirley: [ 2nd Ed: Ch.7, Ch.12
Shirley: { 3rd Ed: Ch.7, Ch.8   }


Programming Assignment #9:
May be done in pairs;
due (electronically submitted) before Friday April 8, 11:00pm


PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin