This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Computer Graphics
Lecture 5
Angel: Interactive Computer
Graphics Camera Setting up 3D Geometric Primitives Pipeline (for direct illumination)
Rendering
3D
Modeling
Transformation
Lighting Transform into 3D world coordinate system
Illuminate according to lighting and reflectance Viewing
Transformation Transform into 3D camera coordinate system Projection
Transformation Transform into 2D screen coordinate system Clipping
Scan
Conversion
Image Clip primitives outside camera’s view
Draw pixels (includes texturing, hidden surface, ...) A 3D Scene
Notice the presence of
the camera, the
projection plane, and
projection
the world
the
coordinate axes Viewing transformations define how to acquire the image
Viewing
on the projection plane
on Viewing Transformations
Create a cameracentered view Camera is at origin
Camera is looking along negative zaxis
Camera’s ‘up’ is aligned with yaxis 2 Basic Steps
Align the two coordinate frames by rotation 2 Basic Steps
Translate to align origins Creating Camera Coordinate Space
Specify a point where the camera is located in world
Specify
space, the eye point
eye
Specify a point in world space that we wish to become
Specify
the center of view, the lookat point
lookat
Specify a vector in world
space that we wish to
space
point up in camera
image, the up vector
up
Intuitive camera
Intuitive
movement
movement Constructing Viewing Transformation, V
Create a vector from eyepoint to lookatpoint. centerx − eye x look = centery − eye y center − eye z
z Normalize and reverse the vector to obtain z axis of the camera
Normalize
system (Described in world system).
system − look
n=
look Constructing Viewing Transformation, V
Construct another important vector from the cross
Construct
product of the upvector and the zaxis.
product up × n = u
This is the xaxis of the camera system (Described in
This
world system).
world Constructing Viewing Transformation, V
One more vector to define, and it is the y axis of the
One
camera system (Described in world system)
camera n×u = v
Now let’s compose the results Constructing Viewing Transformation, V
Therefore, we obtain the rotation component of
Therefore,
viewing transformation.
viewing V Rotate u = v
n Note these are
row vectors Final Viewing Transformation, V
To transform vertices, use this matrix: x ' u x ' y vx z ' = n x
1 0 uy uz vy
ny
0 vz
nz
0 And you get this: − u ⋅ eye x y − v ⋅ eye − n ⋅ eye z 1 1 3D Geometric Primitives Pipeline (for direct illumination)
Rendering
3D
Modeling
Transformation
Lighting Transform into 3D world coordinate system
Illuminate according to lighting and reflectance Viewing
Transformation Transform into 3D camera coordinate system Projection
Transformation Transform into 2D screen coordinate system Clipping
Scan
Conversion
Image Clip primitives outside camera’s view
Draw pixels (includes texturing, hidden surface, ...) Taxonomy of Projections FVFHP Figure 6.10 Taxonomy of Projections Parallel Projection
Center of projection is at infinity
• Direction of projection (DOP) same for all points View
Plane DOP Angel Figure 5.4 Orthographic Projections
DOP perpendicular to view plane
Front Front Angel Figure 5.5 Top Side Orthographic Projection
Simple Orthographic
Transformation Perspective Transformation
First discovered by Donatello, Brunelleschi, and DaVinci during
First
Renaissance
Renaissance
Objects closer to viewer look larger
Parallel lines appear to converge to single point (Vanish point) What is perspective?
Perspective works by representing the light that passes
Perspective
from a scene, through an imaginary rectangle (the
painting), to the viewer's eye. 1) Objects are drawn smaller as their distance from the
observer increases.
observer
2) Spatial foreshortening, which is the distortion of
2)
items when viewed at an angle.
items Onepoint perspective
One vanishing point is
One
typically used for roads,
railroad tracks, or
buildings viewed so that
the front is directly facing
the viewer. Twopoint perspective
Twopoint perspective
can be used to draw the
same objects as onesame
point perspective,
point
rotated: looking at the
corner of a house, or
looking at two forked
roads shrink into the
distance, for example. Threepoint perspective
Threepoint perspective
is usually used for
buildings seen from
above. Perspective Projection
How many vanishing points? 3Point
Perspective 2Point
Perspective 1Point
Perspective
Angel Figure 5.10 Perspective vs. Parallel
Perspective projection
+ Size varies inversely with distance  looks realistic
– Distance and angles are not (in general) preserved
– Parallel lines do not (in general) remain parallel Parallel projection
+ Good for exact measurements
+ Parallel lines remain parallel
– Angles are not (in general) preserved
– Less realistic looking
Less Projection Matrix
We talked about geometric transforms, focusing on
We
modeling transforms
modeling
• Ex: translation, rotation, scale, gluLookAt()
Ex:
gluLookAt()
• These are encapsulated in the OpenGL modelview matrix
These
modelview Projection is also represented as a matrix
Next few slides: representing orthographic and
Next
perspective projection with the projection matrix
projection Perspective Projection
In the real world, objects exhibit perspective
In
foreshortening: distant objects appear
foreshortening distant
smaller
smaller
The basic situation: Perspective Projection
When we do 3D graphics, we think of the
When
screen as a 2D window onto the 3D world:
screen How tall should
this bunny be? Perspective Projection
The geometry of the situation is that of similar triangles.
The
similar
View from above:
View
View
plane X x’ = ? (0,0,0) What is x’ ? P (x, y, z) d Z Perspective Projection
Desired result for a point [x, y, z, 1]T projected onto the
Desired
view plane:
view x' x
=,
d
z
d ⋅x
x
x' =
=
,
z
zd y' y
=
d
z d⋅y
y
y' =
=
,
z
zd What could a matrix look like to do this? z' = d Reminder: Homogeneous Coords
What effect does the following matrix have? x ' 1 y ' 0 = z ' 0 w' 0 0
1
0
0 0 x y 0 0 z 0 10w 0
0
1 Conceptually, the fourth coordinate w is a bit like a scale
Conceptually,
factor
factor A Perspective Projection Matrix
Answer:
1
0
Mperspective = 0 0 00
1
0
01
0 1d 0
0 0 0 A Perspective Projection Matrix
Example: x 1 y 0 = z 0 z d 0 00
1
0
01
0 1d Or, in 3D coordinates: 0 x y 0 0 z 01 x z d , y
,
zd d A Perspective Projection Matrix
Consider the aspect ratio difference between retinal
Consider
plane and screen (or window region):
plane
1
x ' aspect
y 0 z' = 0 w' 0 ' 0 0 1 0 0 1 '
θH
0 − 2tg
2 0 x y 0 0 z 0 w Projection Matrices
Now that we can express perspective projection
Now
as a matrix, we can compose it onto our other
matrices with the usual matrix multiplication
matrices
End result: a single matrix encapsulating
End
modeling, viewing, and projection transforms
modeling, ...
View
Full
Document
This note was uploaded on 06/12/2011 for the course ECON 101 taught by Professor Professor during the Spring '10 term at Cisco Junior College.
 Spring '10
 Professor

Click to edit the document details