Title: Intro to projection
1Intro to projection
2Objectives
- Introduce viewing
- Derive projection matrices
- Viewing pipeline
3Intro to projection
- Viewing requires three basic elements
- Object(s) to be viewed
- Projection surface (image plane)
- Projectors lines that go from the object(s) to
the projection surface - Projectors are lines that either
- converge at a center of projection (COP)
- or are parallel
4Intro to projection
- Standard projections project onto a plane
- Such projections preserve lines
- but not necessarily angles
- Nonplanar projections are needed for applications
such as map construction
5Classical Projections
6Parallel vs Perspective
- Computer graphics treats all projections the same
and implements them with a single pipeline - Classical viewing developed different techniques
for drawing different types - of projections
- Fundamental distinction is between parallel and
perspective viewing (even though mathematically
parallel viewing is the limit of perspective
viewing)
7Parallel Projection
8Perspective Projection
9Orthographic Projection
- Projectors are orthogonal to projection surface
10Advantages and Disadvantages
- Preserves both distance and angle
- Shapes are preserved
- Can be used for measurements
- Building plans
- Manfactured parts
- Cannot see what object really looks like because
many surfaces hidden from view - Often we add the isometric
11Multi-view Orthographic Projection
- Projection plane parallel to principal face
- Usually form front, top, side views
isometric (not orthographic)
top
in CAD and architecture, we often display three
multiviews plus isometric
front
side
12Oblique Projection
- Arbitrary relationship between projectors and
projection plane
13Advantages and Disadvantages
- Can pick the angle to emphasize a particular face
- Architecture plan oblique, elevation oblique
- Angles in faces parallel to
- projection plane are
- preserved while we can
- still see around side
- In physical world, cannot create easily with
simple camera
14Axonometric Projections
- Controls projection plane relative to object
Classify by how many angles of a corner of a
projected cube are the equal to each
other three isometric two dimetric none
trimetric
q 1
q 3
q 2
15Types of Axonometric Projections
16Advantages and Disadvantages
- Parallel Lines preserved but angles are not
- Can see three principal faces of a box-like
object - Some optical illusions possible
- Parallel lines appear to diverge
- Does not look real because far objects are scaled
the same as near objects - Used in CAD applications
17Perspective Projection
- Projectors converge at center of projection
18One-Point Perspective
- One principal face parallel to projection plane
- One vanishing point for cube
19Two-Point Perspective
- On principal direction parallel to projection
plane - Two vanishing points for cube
20Three-Point Perspective
- No principal face parallel to projection plane
- Three vanishing points for cube
21Advantages and Disadvantages
- Objects further from viewer are projected smaller
than the same sized objects closer to the viewer - Looks realistic, gives sense of depth
- Equal distances along a line are not projected
into equal distances (nonuniform foreshortening) - Angles preserved only in planes parallel to the
projection plane - More difficult to construct by hand than parallel
projections (but not more difficult by computer)
22For Computer Viewing
- Derive projection matrices for
- various projections
- Introduce camera frame
- Introduce clipping
- Introduce projection normalization
23Computer Viewing
- There are three aspects of the viewing process
- Selecting a lens
- Setting the projection matrix
- - Positioning the camera
- Setting the view-orientation matrix
- Clipping
- Setting the view volume
24Orthogonal Projection
25Orthogonal Projection
- Set z 0
- Equivalent homogeneous coordinate transformation
Morth
26Oblique Projections
27Oblique Projections
- Direction of projection dop (dopx,dopy,dopz)
z
dop
x
Lets say we project onto z 0 plane
28Oblique Projections
- Direction of projection dop (dopx,dopy,dopz)
ù
é
0
-dopx/dopz
0
1
z
ú
ê
dop
0
dopy/dopz
-
1
0
ú
ê
ú
ê
0
0
0
0
ú
ê
1
0
0
0
û
ë
q
note tanq dopz/dopx
x
29Perspective Projection
30Simple Perspective
- Assume COP (center of projection) is at the
origin and - Projection plane z d, d lt 0, then
31Perspective Equations
- Consider top and side views
xp
yp
zp d
32Homogeneous Coordinate Form
M
? p
q
33Perspective Division
- But recall when w ? 1, we divide by w to return
from homogeneous coordinates - This perspective division yields
- the desired perspective equations
xp
yp
zp d
34Simple Perspective
- Thus for a simple perspective with the COP at
(0,0,0), the image plane at z d
35Viewing Volume
Orthographic View Volume
near and far measured from camera
36Viewing Volume
Perspective View Volume
37Clipping
- Removing the unseen geometry
- Direct (brute-force) solution - solve
silmultaneous equations for - intersections of lines/edges
- at window edges
A point or vertex is visible if xleft lt x lt
xright and ybot lt y lt ytop
38Clipping lines
Pipeline, clip each edge of the window separately
39Clipping polygons
Clip the vertices that are outside of the window
and create new vertices at window border
Result is still a single polygon but may have
more vertices and an odd shape
40Clipping polygons
41Clipping polygons
Bounding box - surrounds each polygon
42Clipping polygons
Trivially reject or accept if the bounding box
falls completely inside or outside.
43Cohen-Sutherland Algorithm
- Region Checks Trivially reject or accept
- for clipping
- Good for large or small windows (all is in or out
of window, respectively) - Each vertex is assigned an 4-bit outcode
- bit 1 - sign of (yt - y), point is above window
- bit 2 - sign of (y-yb), point is below window
- bit 3 - sign of (xr-x), point is right of window
- bit 4 - sign of (x - xl), point is left of window
44Cohen-Sutherland Algorithm
1010 0010 0110
1001 0001 0101
1000 0000 0100
A line can be trivially accepted if both
endpoints have an outcode of 0000. A line can be
trivially rejected if any of the same two bits in
the outcodes are both equal to 1 (both endpoints
are left,right, above, below the window)
45Clipping 3D
Adds far and near clipping planes for 3D viewing
volume
46Normalization
- Rather than derive a different projection matrix
for each type of projection, we can convert all
projections to basic projections with a default
view volume - This strategy allows us to use standard
transformations in the pipeline and makes for
efficient clipping - Volume known as Canonical view volume
47Orthogonal Normalization
normalization ? find transformation to
convert specified clipping volume to default
(right,top,far)
(1,1,1)
(left,bottom,near)
(-1,-1,-1)
Canonical Volume
48Orthogonal Normalization
- Two steps
- Move center to origin
- T(-(leftright)/2, -(bottomtop)/2,-(nearfar)/2))
- Scale to have sides of length 2
- S(2/(right-left),2/(top-bottom),2/(near-far))
49Orthogonal Normalization
Combined with orthogonal projection yields
P MorthST
50Oblique with Normalization
- To use the same projection, we shear but
- don't project
ù
é
0
-dopx/dopz
0
1
z
ú
ê
dop
0
dopy/dopz
-
1
0
ú
ê
ú
ê
0
1
0
0
ú
ê
1
0
0
0
û
ë
q
Note no orthogonal projection (yet)
x
51Oblique with Normalization
- xy shear (z values unchanged)
- Projection matrix
- Normalize as
ù
é
0
-dopx/dopz
0
1
ú
ê
0
dopy/dopz
-
1
0
H
ú
ê
ú
ê
0
1
0
0
ú
ê
1
0
0
0
û
ë
P Morth H
P Morth STH
52Equivalency
53Effect on Clipping
- The projection matrix P STH transforms the
original clipping volume to the default clipping
volume
object
z 1
far plane
DOP
DOP
x -1
x 1
near plane
z -1
Clipping Volume
distorted object (projects correctly)
(seen from top view)
54Perspective Projection
- How to normalize the frustrum of the
- perspective view
- Want to make a canonical volume to clip against,
just like in the parallel case
55Canonical Perspective
- Consider a simple perspective with the COP at the
origin, the far plane at z 1, and a 90 degree
field of view determined by the planes x ?z, - y ?z
xmin
xmax
Zfar
z
Z 1
xz
x-z
x
x
56Effect on Clipping
- Extension to Cohen-Sutherland Clipping
Bit 1 above volume ygt z Bit 2 below
volume ylt-z Bit 3 right of volume
x gtz Bit 4 left of volume x lt-z Bit 5
behind volume z gt 1 Bit 6 in front of
volume zlt zmin
Z 1
xz
x-z
zmin
x
57Pipeline View
transform projection to canonical view
clipping
projection
against canonical
3D ? 2D
- Can also add shear for asymmetric views for
perspective
58Why do we do it this way?
- Normalization allows for a single pipeline to be
used with all (perspective and parallel) desired
views - We keep in four dimensional homogeneous
coordinates as long as possible to retain
three-dimensional information needed for
hidden-surface removal and shading - We standardize clipping
59Computer Viewing
- There are three aspects of the viewing process
- Selecting a lens
- Setting the projection matrix
- - Positioning the camera
- Setting the view-orientation matrix
- Clipping
- Setting the view volume
60Camera coordinates
To set camera, we need one more step...
61Defining and moving the camera
default camera
wanted camera
62Moving the Camera
- We can move the camera to any desired position by
a sequence of rotations and translations - Example side view
- Rotate after moving
- camera away from origin
- Camera View matrix
- Vcam Rcam Tcam
63Whole camera transform
- We can put these together as
- Ttotal Mprojection Vcam
- But where does camera transform come from?
- - Prescribed
- - Generated automatically for games
64Camera movement
- Should mimic a real camera
- -Maintain up-vector
- -Slow turns
- -Avoid accelerations
?
65Camera movement
- Visibility Planning for Camera Control
66Camera movement
- Visibility Planning for Camera Control
Oskan et al 2009
67Camera control Oskan et al
- Precomputation 1) Free-space
Space Sphere Overlapping portals Roadmap
68Camera control Oskan et al
- Precomputation 2) Visibility
69Camera control Oskan et al
Initial Conditions Construct Overlap
Path Refine Subsample
70Camera control Oskan et al