Unformatted text preview: Introduction to
Computer Graphics
CS 445 / 645
Lecture 6
M.C. Escher – Smaller and Smaller (1956) Geometric primitives and
the rendering pipepline Rendering geometric primitives
Describe objects with points, lines, and surfaces
Describe
• Compact mathematical notation
• Operators to apply to those representations Render the objects
• The rendering pipeline Appendix A1A5
H&B Figure 109 Rendering
Generate an image from geometric primitives Rendering
Geometric
Primitives Raster
Image 3D Rendering Example What issues must be addressed by a
3D rendering system? Overview
3D scene representation
3D viewer representation
Visible surface determination
Lighting simulation Overview
3D scene representation
3D viewer representation
Visible surface determination
Lighting simulation
How is the 3D scene
described in a computer? 3D Scene Representation
Scene is usually approximated by 3D primitives
• Point
• Line segment
• Polygon
• Polyhedron
• Curved surface
• Solid object
Solid
• etc. 3D Point
Specifies a location 3D Point
Specifies a location
• Represented by three coordinates
• Infinitely small (x,y,z) 3D Vector
Specifies a direction and a magnitude 3D Vector
Specifies a direction and a magnitude
• Represented by three coordinates
• Magnitude V = sqrt(dx dx + dy dy + dz dz)
• Has no location (dx,dy,dz) Vector Addition/Subtraction
• operation u + v, with:
operation
– Identity 0 : v + 0 = v
Identity
– Inverse  : v + (v) = 0
Inverse
• Addition uses the “parallelogram rule”:
v u+v u v
u v uv v Vector Space
Vectors define a vector space
• They support vector addition
– Commutative and associative
– Possess identity and inverse
• They support scalar multiplication
– Associative, distributive
– Possess identity Affine Spaces
• Vector spaces lack position and distance
– They have magnitude and direction but no location
• Combine the point and vector primitives
– Permits describing vectors relative to a common location
• A point and three vectors define a 3D coordinate system
point
• Pointpoint subtraction yields a vector Coordinate Systems
lGrasp zaxis with hand
lThumb points in direction of zaxis
lRoll fingers from positive xaxis towards positive yaxis
R
R Ehfgwg`scdc
bttÌchs`wd
vvwdr S 9dewg`scdc
bttÌchs`wd
vvwdr Q Q
S Points + Vectors
Points support these operations
• Pointpoint subtraction:
Pointpoint Q QP=v – Result is a vector pointing from P to Q
to
• Vectorpoint addition:
Vectorpoint
– Result is a new point P+v=Q v P • Note that the addition of two points is not defined 3D Line Segment
Linear path between two points 3D Line Segment
Use a linear combination of two points
• Parametric representation:
– P = P1 + t (P2  P1),
), (0 ≤ t ≤ 1) P1 P2 3D Ray
Line segment with one endpoint at infinity
• Parametric representation:
Parametric
– P = P1 + t V, (0 <= t < ∞ ) V
P1 3D Line
Line segment with both endpoints at infinity
• Parametric representation:
Parametric
– P = P1 + t V, (∞ < t < ∞ ) P1 V 3D Line – Slope Intercept
Slope
Slope =m
= rise / run
rise Slope
Slope P = (x, y) y = (y  y1) / (x  x1)
= (y2  y1) / (x2  x1)
(y2 P2 = (x2, y2)
P1 = (x1, y1) Solve for y:
y = [(y2  y1)/(x2  x1)]x + [(y2y1)/(x2  x1)]x1 + y1 or: y = mx + b x Euclidean Spaces
Q: What is the distance function between points
Q:
and vectors in affine space?
and
A: Dot product
• Euclidean affine space = affine space plus dot product
• Permits the computation of distance and angles Dot Product
• The dot product or, more generally, inner product of
The dot
inner
two vectors is a scalar:
two
v1 • v2 = x1x2 + y1y2 + z1z2
(in 3D)
(in
v
u θ Dot Product
Useful for many purposes
• Computing the length (Euclidean Norm) of a vector:
Computing
– length(v) = v = sqrt(v • v)
• Normalizing a vector, making it unitlength: v = v / v
v
• Computing the angle between two vectors:
– u • v = u v cos(θ)
v • Checking two vectors for orthogonality
– u • v = 0.0 u θ Dot Product
Projecting one vector onto another
Projecting
• If v is a unit vector and we have another vector, w
If
• We can project w perpendicularly onto v
We
w
v u • And the result, u, has length w • v
has u = w cos(θ ) v •w
=w
v w =v • w Dot Product
Is commutative
• u•v=v•u Is distributive with respect to addition
• u • (v + w) = u • v + u • w Cross Product
The cross product or vector product of two vectors is a
The cross
vector
vector:
vector: ux
v1 × v 2 = x1 uy
y1 uz
z1 x2 y2 z2 determinant y1 z 2 − y 2 z 1 = − ( x1 z 2 − x 2 z1) x 1 y 2 − x 2 y1 The cross product of two vectors is orthogonal to both
Righthand rule dictates direction of cross product Cross Product Right Hand Rule
λ
λ λ
λ See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the
beginning of A and your fingers point in the
direction of A
Twist your hand about the Aaxis such that B
extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb
will point in the direction of the cross product Cross Product Right Hand Rule
λ
λ λ
λ See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the
beginning of A and your fingers point in the
direction of A
Twist your hand about the Aaxis such that B
extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb
will point in the direction of the cross product Cross Product Right Hand Rule
l
l l
l See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the
beginning of A and your fingers point in the
direction of A
Twist your hand about the Aaxis such that B
extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb
will point in the direction of the cross product Cross Product Right Hand Rule
l
l l
l See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the
beginning of A and your fingers point in the
direction of A
Twist your hand about the Aaxis such that B
extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb
will point in the direction of the cross product Cross Product Right Hand Rule
l
l l
l See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the
beginning of A and your fingers point in the
direction of A
Twist your hand about the Aaxis such that B
extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb
will point in the direction of the cross product Other helpful formulas
Length = sqrt (x2  x1)2 + (y2  y1)2
Midpoint, p2, between p1 and p3
• p2 = ((x1 + x3) / 2, (y1 + y3) / 2)) Two lines are perpendicular if:
• M1 = 1/M2
• cosine of the angle between them is 0
• Dot product = 0 3D Plane
A linear combination of three points P2
P1 P3 3D Plane
A linear combination of three points
N = (a,b,c) • Implicit representation:
Implicit
– ax + by + cz + d = 0, or
ax
– P·N + d = 0
• N is the plane “normal”
– Unitlength vector P2
P1 P3
d – Perpendicular to plane Origin 3D Sphere
All points at distance “r” from point “(cx, cy, cz)”
• Implicit representation:
– (x  cx)2 + (y  cy)2 + (z  cz)2 = r 2
• Parametric representation:
– x = r cos(φ) cos(Θ) + cx
– y = r cos(φ) sin(Θ) + cy
– z = r sin(φ) + cz r 3D Geometric Primitives
More detail on 3D modeling later in course
More
• Point
• Line segment
• Polygon
• Polyhedron
• Curved surface
• Solid object
Solid
• etc.
H&B Figure 10.46 Take a breath
We’re done with the primitives
Now we’re moving on to study how graphics uses
Now
these primitives to make pretty pictures
these Rendering 3D Scenes
Transform
Illuminate
Transform
Clip
Project
Rasterize Model & Camera
Parameters Rendering Pipeline Framebuffer Display Camera Models
The most common model is pinhole camera
The
• All captured light rays arrive along paths toward focal point
All
without lens distortion
(everything is in focus)
(everything
• Sensor response
Sensor
proportional to radiance
proportional
Other models consider ...
Depth of field
Motion blur
Lens distortion View plane Eye position
(focal point) Camera Parameters
What are the parameters of a camera? Camera Parameters
Position
• Eye position (px, py, pz) Orientation • View direction (dx, dy, dz)
• Up direction (ux, uy, uz) Aperture “Look at”
Point • Field of view (xfov, yfov) Film plane
Film
• “Look at” point
• View plane normal View
Plane Eye
Position Moving the camera
Up
Back Towards Right View Frustum The Rendering Pipeline
Transform
Illuminate
Transform
Clip
Project
Rasterize Model & Camera
Parameters Rendering Pipeline Framebuffer Display Rendering: Transformations
We’ve learned about transformations
But they are used in three ways:
• Modeling transforms
• Viewing transforms (Move the camera)
• Projection transforms (Change the type of camera) The Rendering Pipeline: 3D
Scene graph
Object geometry Result: Modeling
Transforms • All vertices of scene in shared 3D “world” coordinate system
All Lighting
Calculations • Vertices shaded according to lighting model
Vertices Viewing
Transform • Scene vertices in 3D “view” or “camera” coordinate system
Scene Clipping • Exactly those vertices & portions of polygons in view frustum
Exactly Projection
Transform • 2D screen coordinates of clipped vertices
2D The Rendering Pipeline: 3D
Scene graph
Object geometry
Modeling
Transforms
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform Result:
• All vertices of scene in shared 3D “world” coordinate system
All Rendering: Transformations
Modeling transforms
• Size, place, scale, and rotate objects and parts of the
Size,
model w.r.t. each other
model
• Object coordinates > world coordinates
Y
Y Z
X
Z X The Rendering Pipeline: 3D
Scene graph
Object geometry
Modeling
Transforms
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform Result:
•All geometric primitives are illuminated Lighting Simulation
Lighting parameters Light
Source • Light source emission
• Surface reflectance
• Atmospheric attenuation Surface • Camera response
N Camera N Lighting Simulation
Direct illumination Light
Source • Ray casting
• Polygon shading
N Global illumination
• Ray tracing Surface
N • Monte Carlo methods
• Radiosity methods
More on these
methods later! Camera N The Rendering Pipeline: 3D
Scene graph
Object geometry
Modeling
Transforms
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform Result:
• Scene vertices in 3D “view” or “camera” coordinate system
Scene Rendering: Transformations
Viewing transform
• Rotate & translate the world to lie directly in front of
Rotate
the camera
the
– Typically place camera at origin
– Typically looking down Z axis
• World coordinates view coordinates
view The Rendering Pipeline: 3D
Scene graph
Object geometry
Modeling
Transforms
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform Result:
• Remove geometry that is out of view
Remove Assignment 2
Due two and a half weeks from today
• Project description available online
• We’ll discuss details in class on Monday The Rendering Pipeline: 3D
Scene graph
Object geometry
Modeling
Transforms
Lighting
Calculations
Viewing
Transform
Clipping
Projection
Transform Result:
• 2D screen coordinates of clipped vertices
2D Rendering: Transformations
Projection transform
• Apply perspective foreshortening
– Distant = small: the pinhole camera model
Distant
pinhole
• View coordinates screen coordinates
View Rendering: Transformations
Perspective Camera
Perspective Orthographic Camera Rendering 3D Scenes
Transform
Illuminate
Transform
Clip
Project
Rasterize Model & Camera
Parameters Rendering Pipeline Framebuffer Display Rasterize
Convert screen coordinates to pixel colors Summary
Geometric primitives
• Points, vectors Operators on these primitives
• Dot product, cross product, norm The rendering pipeline
• Move models, illuminate, move camera, clip, project to
Move
display, rasterize
display, ...
View
Full
Document
This note was uploaded on 01/23/2012 for the course CS 445 taught by Professor Bloomfield,a during the Spring '08 term at UVA.
 Spring '08
 BLOOMFIELD,A
 Computer Graphics

Click to edit the document details