Computing & Information Sciences Kansas State University CG Basics 4 of 8: ViewingCIS 636/736:...
-
Upload
irma-bradford -
Category
Documents
-
view
216 -
download
2
Transcript of Computing & Information Sciences Kansas State University CG Basics 4 of 8: ViewingCIS 636/736:...
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
CIS 636Introduction to Computer Graphics
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course pages: http://snipurl.com/1y5gc
Course web site: http://www.kddresearch.org/Courses/CIS636
Instructor home page: http://www.cis.ksu.edu/~bhsu
Readings:
Slides based on Viewing 1-3, http://www.cs.brown.edu/courses/cs123/lectures.htm Sections 2.6 – 2.7, Eberly 2e – see http://snurl.com/1ye72
OpenGL API Documentation: http://www.opengl.org/documentation/
Lab 2: glFrustum(), gluPerspective() (http://snurl.com/1zt6z)
CG Basics 4 of 8:Detailed Introduction to Viewing
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Online Recorded Lectures for CIS 636
Introduction to Computer Graphics Project Topics for CIS 636
Computer Graphics Basics (8) 1. Mathematical Foundations – Week 2
2. Rasterizing and 2-D Clipping – Week 3
3. OpenGL Primer 1 of 3 – Week 3
4. Detailed Introduction to 3-D Viewing – Week 4
5. OpenGL Primer 2 of 3 – Week 5
6. Polygon Rendering – Week 6
7. OpenGL Primer 3 of 3 – Week 8
8. Visible Surface Determination – Week 9
Recommended Background Reading for CIS 636
Shared Lectures with CIS 736 (Computer Graphics) Regular in-class lectures (35) and labs (7)
Guidelines for paper reviews – Week 7
Preparing term project presentations, demos for graphics – Week 11
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Lecture Outline
History of Projections
Normalizing and Viewing Transformations
Perspective (to Parallel) Transformation
Kinds of Projections Parallel
Orthographic: top, front, side, other
Axonometric: isometric, dimetric, trimetric
Oblique: cavalier, cabinet
Other
Perspective: 1-point, 2-point, 3-point
Viewing in OpenGL
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
History
Geometrical Constructions
Types of Projection
Projection in Computer Graphics
From 3-D to 2-D: Orthographic and Perspective Projection – Part 1
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Parallel projections used for engineering and architecture because they can be used for measurements
Perspective imitates our eyes or camera, looks more natural
Logical Relationship amongTypes of Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Same method as multiview orthographic projections, except projection plane not parallel to any of the coordinate planes; parallel lines are equally foreshortened
Isometric: Angles between all three principal axes are equal (120º). The same scale ratio applies along each axis
Dimetric: Angles between two of the principal axes are equal; need two scale ratios
Trimetric: Angles different between the three principal axes; need three scale ratios
Note: different names for different views, but all part of a continuum of parallel projections of the cube; these differ in where the projection plane is relative to its cube
dimetric
dimetric
isometric
dimetric
orthographic
Carlbom Fig. 3-8
Axonometric Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Used for: catalogue illustrations patent office records furniture design structural design
Pros: don’t need multiple views illustrates 3D nature of object measurements can be made to scale along principal axes
Cons: lack of foreshortening creates distorted appearance more useful for rectangular than curved shapes
Construction of isometric projection:projection plane cuts each principal axis by 45°
Example
Carlbom Fig.2.2
Isometric Projection:Special Case of Axonometric
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Projectors are at an oblique angle to the projection plane; view cameras have accordion housing, used for skyscrapers
Pros: can present the exact shape of one face of an object (can take accurate
measurements): better for elliptical shapes than axonometric projections, better for “mechanical” viewing
lack of perspective foreshortening makes comparison of sizes easier
displays some of object’s 3D appearance
Cons: objects can look distorted if careful choice not made about position of
projection plane (e.g., circles become ellipses)
lack of foreshortening (not realistic looking)
obliqueperspective
Oblique Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Source: http://www.usinternet.com/users/rniederman/star01.htm
View Camera
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Construction of an obliqueparallel projection
Plan oblique projection of a city(Carlbom Fig. 2-6)
Front oblique projection of a radio
(Carlbom Fig. 2-4)
Examples of Oblique Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Rules for placing projection plane for oblique views
Projection plane should be set parallel to one of: most irregular of principal faces, or one which contains circular or
curved surfaces
longest principal face of object
face of interest
Projection plane parallel to circular face Projection plane not parallel to circular face
Example and Principles:Oblique View
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Cavalier: Angle between projectors and projection plane is 45º. Perpendicular faces are projected at full scale
Cabinet: Angle between projectors and projection plane is arctan(2) = 63.4º. Perpendicular faces are projected at 50% scale
cavalier projection of unit cube
cabinet projection of unit cube
Main Types of Oblique Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
multiview orthographic
cavalier cabinet
Carlbom Fig. 3-2
Examples of Orthographic andOblique Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Assume object face of interest lies in principal plane, i.e., parallel to xy, yz, or
zx planes. (DOP = Direction of Projection, VPN = View Plane Normal)
1) Multiview Orthographic
– VPN || a principal coordinate axis
– DOP || VPN
– shows single face, exact measurements
2) Axonometric
– VPN || a principal coordinate axis
– DOP || VPN
– adjacent faces, none exact, uniformly foreshortened (as a function of angle between face normal and DOP)
3) Oblique
– VPN || a principal coordinate axis
– DOP || VPN
– adjacent faces, one exact, others uniformly foreshortened
Parallel Projections: Summary
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Used for: advertising presentation drawings for architecture, industrial design, engineering fine art
Pros: gives a realistic view and feeling for 3D form of object
Cons: does not preserve shape of object or scale (except where object intersects
projection plane)
Different from a parallel projection because parallel lines not parallel to the projection plane converge size of object is diminished with distance foreshortening is not uniform
Perspective Projections
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
One Point Perspective (z-axis vanishing point)
Three Point Perspective(z, x, and y-axis vanishing points)
Two Point Perspective (z, and x-axis vanishing points)
z
Vanishing Points [1]
For right-angled forms whose face normals are perpendicular to the x, y, z coordinate axes, the number of vanishing points = number of principal coordinate axes intersected by projection plane
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
What happens if same form is turned so that its face normals are not perpendicular to x, y, z coordinate axes?
• Although projection plane only intersects one axis (z), three vanishing points were created
• Note: can achieve final results which are identical to previous situation in which projection plane intersected all three axes
• New viewing situation: cube rotated, face normals no longer perpendicular to any principal axes
• Note: unprojected cube depicted here with parallel projection
Perspective drawing of rotated cube
Vanishing Points [2]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
We’ve seen two pyramid geometries for understanding perspective projection:
Combining these 2 views:
1. perspective image is intersection of a plane with light rays from object to eye (COP)
2. perspective image is result of foreshortening due to convergence of some parallel lines toward vanishing points
Vanishing Points and View Point [1]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Project parallel lines AB, CD on xy plane Projectors from the eye to AB and CD define two planes, which meet
in a line which contains the view point, or eye This line does not intersect the projection plane (XY), because parallel
to it. Therefore there is no vanishing point
Vanishing Points and View Point [2]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Lines AB and CD (this time with A and C behind projection plane) projected on xy plane: A’B and C’D
Note: A’B not parallel to C’D
Projectors from eye to A’B and C’D define two planes which meet in a line containing view point
This line intersects projection plane
Point of intersection is vanishing point
C
A
Vanishing Points and View Point [3]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Analogous to size of film used in a camera Determines proportion of width to height of image displayed on screen Square viewing window has aspect ratio of 1:1 Movie theater “letterbox” format has aspect ratio of 2:1 NTSC television has aspect ratio of 4:3, HDTV is 16:9
Ko
dak H
DT
V 1
6:9
NT
SC
4: 3
Aspect Ratio
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Determines amount of perspective distortion in picture parallel projection: none
wide-angle lens: lots
In a frustum, two viewing angles Width and height angles
We specify Height angle
Get Width angle from
Aspect ratio * Height angle
Choosing View angle Analogous to photographer choosing a specific type of lens
e.g., wide-angle or telephoto (narrow angle) lens
View Angle [1]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Lenses made for distance shots often have a nearly parallel viewing angle
and cause little perspective distortion, though they foreshorten depth
Wide-angle lenses cause a lot of perspective distortion
Resulting pictures
View Angle [2]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Real cameras have a roll of film that captures pictures
Synthetic camera “film” is a rectangle on an infinite film plane that contains image of scene
Why haven’t we talked about the “film” in our synthetic camera, other than mentioning its aspect ratio?
How is the film plane positioned relative to the other parts of the camera? Does it lie between the near and far clipping planes? Behind them?
Turns out that fine positioning of Film plane doesn’t matter. Here’s why:
for a parallel view volume, as long as the film plane lies in front of the scene, parallel projection onto film plane will look the same no matter how far away film plane is from scene
same is true for perspective view volumes, because the last step of computing the perspective projection is a transformation that stretches the perspective volume into a parallel volume
In general, it is convenient to think of the film plane as lying at the eye point (Position)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
“Where’s My Film?”
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Some camera models take a Focal length Focal Length is a measure of ideal focusing range; approximates behavior of
real camera lens Objects at distance of Focal length from camera are rendered in focus; objects
closer or farther away than Focal length get blurred Focal length used in conjunction with clipping planes Only objects within view volume are rendered, whether blurred or not. Objects
outside of view volume still get discarded
Focal Length
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Non-oblique view volume:
Oblique view volume:
Look vector at an angleto film plane
Limitations of this Camera Model
Look vector perpendicular to film plane
Can create the following view volumes: perspective: positive view angle parallel: zero view angle
Cannot create oblique view volume Non-oblique vs. oblique view volumes:
For example, view cameras with bellows are used to take pictures of (tall) buildings.
Film plane is parallel to the façade, while camera points up This is oblique view volume, with façade undistorted
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Carlbom, Ingrid and Paciorek, Joseph, “Planar Geometric Projections
and Viewing Transformations,” Computing Surveys, Vol. 10, No. 4
December 1978
Kemp, Martin, The Science of Art, Yale University Press, 1992
Mitchell, William J., The Reconfigured Eye, MIT Press, 1992
Foley, van Dam, et. al., Computer Graphics: Principles and Practice,
Addison-Wesley, 1995
Wernecke, Josie, The Inventor Mentor, Addison-Wesley, 1994
References
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Projection in Computer Graphics
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
More concrete way to say the same thing as orientation soon you’ll learn how to express orientation in terms of Look and Up vectors
Look Vector the direction the camera is pointing three degrees of freedom; can be any vector in 3-space
Up Vector determines how the camera is rotated around the Look vector for example, whether you’re holding the camera horizontally or vertically (or
in between) projection of Up vector must be in the plane perpendicular to the look vector
(this allows Up vector to be specified at an arbitrary angle to its Look vector)
Up vectorLook vector
Position
projection of Up vector
Look and Up Vectors
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
D = P1 – P0 = (x1 – x0, y1 – y0)
Leave PEi as an arbitrary point on the clip edge; it’s a free
variable and drops out
Clip Edgei Normal Ni PEiP0-PEi
left: x = xmin (-1,0) (xmin, y) (x0- xmin,y0-y)
right: x = xmax (1,0) (xmax,y) (x0- xmax,y0-y)
bottom: y = ymin (0,-1) (x, ymin) (x0-x,y0- ymin)
top: y = ymax (0,1) (x, ymax) (x0-x,y0- ymax)
DiN
iEPP
iN
t
)0
(
)01
(
)min0
(
xx
xx
)01
(
)max0
(
xx
xx
)01
(
)min0
(
yy
yy
)01
(
)max0
(
yy
yy
Calculations for Parametric Line Clipping Algorithm
Clipping:Parametric Clipping, Review
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Volume of space between Front and Back clipping planes defines what camera can see
Position of planes defined by distance along Look vector
Objects appearing outside of view volume don’t get drawn
Objects intersecting view volume get clipped
Front clipping plane
Back clipping plane
Clipping:Front and Back Clipping Planes
[1]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Reasons for Front (near) clipping plane:
Don’t want to draw things too close to the camera would block view of rest of scene
objects would be prone to distortion
Don’t want to draw things behind camera wouldn’t expect to see things behind the camera
in the case of perspective camera, if we decided to draw things behind camera, they would appear upside-down and inside-out because of perspective transformation
Reasons for Back (far) clipping plane:
Don’t want to draw objects too far away from camera distant objects may appear too small to be visually significant, but still take long
time to render
by discarding them we lose a small amount of detail but reclaim a lot of rendering time
alternately, scene may be filled with many significant objects
for visual clarity, we may wish to declutter scene by rendering those nearest camera and discarding rest
Clipping:Front and Back Clipping Planes
[2]
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Have you ever played a video game and all of the sudden some object pops up in the background (e.g. a tree in a racing game)? That’s the object coming inside the far clip plane.
The old hack to keep you from noticing the pop-up is to add fog in the distance. A classic example of this is from Turok: Dinosaur Hunter
Now all you notice is fog and how little you can actually see. This practically defeats the purpose of an outdoor environment! And you can still see pop-up from time to time.
Thanks to fast hardware and level of detail algorithms, we can push the far plane back now and fog is much less prevalent
Putting the near clip plane as far away as possible helps Z precision. Sometimes in a game you can position the camera in the right spot so that the front of an object gets clipped letting you see inside of it.
Clipping:Front and Back Clipping Planes
[3]
Then (1997)
Now (2008)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
From Position, Look vector, Up vector, Aspect ratio, Height angle, Clipping planes, and (optionally) Focal length together specify a truncated view volume
Truncated view volume is a specification of bounded space that camera can “see”
2D view of 3D scene can be computed from truncated view volume and projected onto film plane
Truncated view volumes come in two flavors: parallel and perspective
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
View Volume Specification
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Limiting view volume useful for eliminating extraneous objects Orthographic parallel projection has width and height view angles of zero
Height
Width
Look vector
Near distance
Position
Far distance
Up vector
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Truncated View Volume (Cuboid) for
Orthographic Parallel Projection
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Removes objects too far from Position Otherwise would merge into “blobs”
Removes objects too close to Position Would be excessively distorted
Position
Near distance
Far distance
Height angle
Width angle =
Look vector
Up vectorHeight angle • Aspect ratio
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Truncated View Volume (Frustum) for
Perspective Projection
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Reduce degrees of freedom
Five steps to specifying view volume
1. Position the camera and therefore its view/film plane
2. Point it at what you want to see with camera in desired orientation
3. Define the field of view for a perspective view volume, aspect ratio of film and angle of view:
somewhere between wide angle, normal, and zoom
for a parallel view volume, width and height)
4. Choose perspective or parallel projection
5. Determine focal distance
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Stage One:Specifying a View Volume
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Placement of view volume (visible part of world) specified by camera’s position and orientation
Position (a point) Look and Up vectors
Shape of view volume specified by horizontal and vertical view angles front and back clipping planes
Perspective projection: projectors intersect at Position Parallel projection: projectors parallel to Look vector, but never intersect (or
intersect at infinity) Coordinate Systems
world coordinates – standard right-handed xyz 3-space viewing reference coordinates – camera-space right handed coordinate system (u, v, n);
origin at Position and axes rotated by orientation; used for transforming arbitrary view into canonical view
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Specifying a View Volume
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
We have now specified an arbitrary view using our viewing parameters Problem: map arbitrary view specification to 2D picture of scene. This is
hard, both for clipping and for projection Solution: reduce to a simpler problem and solve
Note: Look vector along negative, not positive, z-axis is arbitrary but makes math easier
– Need: View specification from which it is easy to take pictures– Canonical view: from the origin, looking down negative z-axis
– parallel projection– sits at origin: Position = (0, 0, 0)– looks along negative z-axis: Look vector = (0, 0, –1)– oriented upright: Up vector = (0, 1, 0)– film plane extending from –1 to 1 in x and y
– think of the scene as lying behind window and we’re looking through the window
up
n
v
u
Arbitrary View Volume too Complex
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Our goal is to transform our arbitrary view and the world to the canonical view volume, maintaining the relationship between view volume and world, then take picture for parallel view volume, transformation is affine: made up of translations,
rotations, and scales in the case of a perspective view volume, it also contains a non-affine†
perspective transformation that frustum into a parallel view volume, a cuboid
the composite transformation that will transform the arbitrary view volume to the canonical view volume, named the normalizing transformation, is still a 4x4 homogeneous coordinate matrix that typically has an inverse
easy to clip against this canonical view volume; clipping planes are axis-aligned!
projection using the canonical view volume is even easier: just omit the z-coordinate
for oblique parallel projection, a shearing transform is part of the composite transform, to “de-oblique” the view volume
† Affine transformations preserve parallelism but not lengths and angles. The perspective transformation is a type of non-affine transformation known as a projective transformation, which does not preserve parallelism
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Normalizing toCanonical View Volume
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Problem of taking a picture has now been reduced to problem of finding correct normalizing transformation
It is a bit tricky to find the rotation component of the normalizing transformation.
However, it is easier to find the inverse of this rotational component (trust us)
So we’ll digress for a moment and focus our attention on the inverse of the normalizing transformation, which is called the viewing transformation.
The viewing transformation turns the canonical view into the arbitrary view, or (x, y, z) to (u, v, n)
Viewing Transformation Normalizing Transformation
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
We know the view specification: Position, Look vector, and Up vector We need to derive an affine transformation from these parameters that
will translate and rotate the canonical view into our arbitrary view the scaling of the film (i.e. the cross-section of the view volume) to make a
square cross-section will happen at a later stage, as will clipping
Translation is easy to find: we want to translate the origin to the point Position; therefore, the translation matrix is
Rotation is harder: how do we generate a rotation matrix from the viewing specifications that will turn x, y, z, into u, v, n? a digression on rotation will help answer this
1000
100
010
001
)(z
y
x
Pos
Pos
Pos
PositionT
Building Viewing Transformationfrom View Specification
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
3 x 3 rotation matrices We learned about 3 x 3 matrices that “rotate” the world (we’re leaving out the
homogeneous coordinate for simplicity) When they do, the three unit vectors that used to point along the x, y, and z
axes are moved to new positions Because it is a rigid-body rotation
the new vectors are still unit vectors the new vectors are still perpendicular to each other the new vectors still satisfy the “right hand rule”
Any matrix transformation that has these three properties is a rotation about some axis by some amount!
Let’s call the three x-axis, y-axis, and z-axis-aligned unit vectors e1, e2, e3
Writing out:
0
0
1
1e
0
1
0
2e
1
0
0
3e
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Rotation [1]
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Let’s call our rotation matrix M and suppose that it has columns v1, v2, and v3:
When we multiply M by e1, what do we get?
Similarly for e2 and e3:
321 vvvM
23212
0
1
0
vvvvMe
33213
1
0
0
vvvvMe
13211
0
0
1
vvvvMe
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Rotation [2]
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Thus, for any matrix M, we know that Me1 is the first column of M
If M is a rotation matrix, we know that Me1 (i.e., where e1 got rotated to) must be a unit-length vector (because rotations preserve length)
Since Me1 = v1, the first column of any rotation matrix M must be a unit vector
Also, the vectors e1 and e2 are perpendicular…
So if M is a rotation matrix, the vectors Me1 and Me2 are perpendicular… (if you start with perpendicular vectors and rotate them, they’re still perpendicular)
But these are the first and second columns of M … Ditto for the other two pairs
As we noted in the slide on rotation matrices, for a rotation matrix with columns vi
columns must be unit vectors: ||vi|| = 1
columns are perpendicular: vi • vj = 0 (i j)Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Rotation [3]
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Therefore (for rotation matrices)
We can write this matrix of vi•vj dot products as
where MT is a matrix whose rows are v1, v2, and v3
Also, for matrices in general, M-1M = I, (actually, M-1 exists only for “well-behaved” matrices)
Therefore, for rotation matrices only we have just shown that M-1 is simply MT
MT is trivial to compute, M-1 takes considerable work: big win!
100
010
001
332313
322212
312111
vvvvvv
vvvvvv
vvvvvv
IMM T
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Rotation [4]
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Summary If M is a rotation matrix, then its columns are pairwise perpendicular
and have unit length Inversely, if the columns of a matrix are pairwise perpendicular and
have unit length and satisfy the right-hand rule, then the matrix is a rotation
For such a matrix,
100
010
001
MM T
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
Rotation [5]
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Summary
History of Projections
Normalizing and Viewing Transformations
Perspective (to Parallel) Transformation
Kinds of Projections Parallel
Orthographic: top, front, side, other
Axonometric: isometric, dimetric, trimetric
Oblique: cavalier, cabinet
Other
Perspective: 1-point, 2-point, 3-point
Viewing in OpenGL
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Terminology
World Coordinates
Screen Coordinates
Normalizing Transformation
Viewing Transformation
Duality
Perspective (to Parallel) Transformation
Projections Parallel
Orthographic: top, front, side, other
Axonometric: isometric, dimetric, trimetric
Oblique: cavalier, cabinet
Other
Perspective: 1-point, 2-point, 3-point
Computing & Information SciencesKansas State University
CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics
Next: OpenGL Tutorial 2
Four More Short OpenGL Tutorials from SIGGRAPH 2000
Vicki Shreiner: Animation and Depth Buffering Double buffering
Illumination: light positioning, light models, attenuation
Material properties
Animation basics in OpenGL
Vicki Schreiner: Imaging and Raster Primitives
Ed Angel: Texture Mapping
Dave Shreiner: Advanced Topics Display lists and vertex arrays
Accumulation buffer
Fog
Stencil buffering
Fragment programs (to be concluded in Tutorial 3)