Title: Introduction to Computer Graphics CS 445 / 645
1Introduction to Computer GraphicsCS 445 / 645
- Lecture 6
- Geometric primitives andthe rendering pipepline
M.C. Escher Smaller and Smaller (1956)
2Rendering geometric primitives
- Describe objects with points, lines, and surfaces
- Compact mathematical notation
- Operators to apply to those representations
- Render the objects
- The rendering pipeline
- Appendix A1-A5
HB Figure 109
3Rendering
- Generate an image from geometric primitives
Rendering
Geometric Primitives
Raster Image
43D Rendering Example
What issues must be addressed by a 3D rendering
system?
5Overview
- 3D scene representation
- 3D viewer representation
- Visible surface determination
- Lighting simulation
6Overview
- 3D scene representation
- 3D viewer representation
- Visible surface determination
- Lighting simulation
How is the 3D scene described in a computer?
73D Scene Representation
- Scene is usually approximated by 3D primitives
- Point
- Line segment
- Polygon
- Polyhedron
- Curved surface
- Solid object
- etc.
83D Point
93D Point
- Specifies a location
- Represented by three coordinates
- Infinitely small
(x,y,z)
103D Vector
- Specifies a direction and a magnitude
113D 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)
12Vector Addition/Subtraction
- operation u v, with
- Identity 0 v 0 v
- Inverse - v (-v) 0
- Addition uses the parallelogram rule
v
u
-v
v
u-v
-v
u
13Vector 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
14Affine 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 3-D coordinate
system - Point-point subtraction yields a vector
15Coordinate Systems
- Grasp z-axis with hand
- Thumb points in direction of z-axis
- Roll fingers from positive x-axis towards
positive y-axis
16Points Vectors
- Points support these operations
- Point-point subtraction Q - P v
- Result is a vector pointing from P to Q
- Vector-point addition P v Q
- Result is a new point
- Note that the addition of two points is not
defined
173D Line Segment
- Linear path between two points
183D Line Segment
- Use a linear combination of two points
- Parametric representation
- P P1 t (P2 - P1), (0 ? t ? 1)
P2
P1
193D Ray
- Line segment with one endpoint at infinity
- Parametric representation
- P P1 t V, (0 lt t lt ?)
V
P1
203D Line
- Line segment with both endpoints at infinity
- Parametric representation
- P P1 t V, (-? lt t lt ?)
V
P1
213D Line Slope Intercept
- Slope m
- rise / run
- Slope (y - y1) / (x - x1) (y2 - y1) / (x2
- x1) - Solve for y
- y (y2 - y1)/(x2 - x1)x -(y2-y1)/(x2 -
x1)x1 y1 - or y mx b
22Euclidean Spaces
- Q What is the distance function between points
and vectors in affine space? - A Dot product
- Euclidean affine space affine space plus dot
product - Permits the computation of distance and angles
23Dot Product
- The dot product or, more generally, inner product
of two vectors is a scalar - v1 v2 x1x2 y1y2 z1z2 (in 3D)
24Dot Product
- Useful for many purposes
- Computing the length (Euclidean Norm) of a
vector - length(v) v sqrt(v v)
- Normalizing a vector, making it unit-length v
v / v - Computing the angle between two vectors
- u v u v cos(?)
- Checking two vectors for orthogonality
- u v 0.0
25Dot Product
- Projecting one vector onto another
- If v is a unit vector and we have another vector,
w - We can project w perpendicularly onto v
- And the result, u, has length w v
26Dot Product
- Is commutative
- u v v u
- Is distributive with respect to addition
- u (v w) u v u w
27Cross Product
- The cross product or vector product of two
vectors is a vector - The cross product of two vectors is orthogonal to
both - Right-hand rule dictates direction of cross
product
28Cross Product Right Hand Rule
- See http//www.phy.syr.edu/courses/video/RightHan
dRule/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 A-axis 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
29Cross Product Right Hand Rule
- See http//www.phy.syr.edu/courses/video/RightHan
dRule/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 A-axis 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
30Cross Product Right Hand Rule
- See http//www.phy.syr.edu/courses/video/RightHan
dRule/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 A-axis 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
31Cross Product Right Hand Rule
- See http//www.phy.syr.edu/courses/video/RightHan
dRule/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 A-axis 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
32Cross Product Right Hand Rule
- See http//www.phy.syr.edu/courses/video/RightHan
dRule/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 A-axis 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
33Other 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
343D Plane
- A linear combination of three points
P3
P2
P1
353D Plane
- A linear combination of three points
- Implicit representation
- ax by cz d 0, or
- PN d 0
- N is the plane normal
- Unit-length vector
- Perpendicular to plane
N (a,b,c)
P3
P2
P1
d
363D 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
373D Geometric Primitives
- More detail on 3D modeling later in course
- Point
- Line segment
- Polygon
- Polyhedron
- Curved surface
- Solid object
- etc.
HB Figure 10.46
38Take a breath
- Were done with the primitives
- Now were moving on to study how graphics uses
these primitives to make pretty pictures
39Rendering 3D Scenes
40Camera Models
- The most common model is pin-hole camera
- All captured light rays arrive along paths toward
focal point without lens distortion (everything
is in focus) - Sensor response proportional to radiance
View plane
Other models consider ... Depth of field Motion
blur Lens distortion
Eye position (focal point)
41Camera Parameters
- What are the parameters of a camera?
42Camera Parameters
- Position
- Eye position (px, py, pz)
- Orientation
- View direction (dx, dy, dz)
- Up direction (ux, uy, uz)
- Aperture
- Field of view (xfov, yfov)
- Film plane
- Look at point
- View plane normal
View Plane
Up direction
Look at Point
back
View direction
Eye Position
right
43Moving the camera
Up
Back
Towards
Right
View Frustum
44The Rendering Pipeline
45Rendering Transformations
- Weve learned about transformations
- But they are used in three ways
- Modeling transforms
- Viewing transforms (Move the camera)
- Projection transforms (Change the type of camera)
46The Rendering Pipeline 3-D
Scene graphObject geometry
- Result
- All vertices of scene in shared 3-D world
coordinate system - Vertices shaded according to lighting model
- Scene vertices in 3-D view or camera
coordinate system - Exactly those vertices portions of polygons in
view frustum - 2-D screen coordinates of clipped vertices
ModelingTransforms
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
47The Rendering Pipeline 3-D
48Rendering Transformations
- Modeling transforms
- Size, place, scale, and rotate objects and parts
of the model w.r.t. each other - Object coordinates -gt world coordinates
Y
Z
X
49The Rendering Pipeline 3-D
50Lighting Simulation
- Lighting parameters
- Light source emission
- Surface reflectance
- Atmospheric attenuation
- Camera response
Light Source
Surface
Camera
51Lighting Simulation
- Direct illumination
- Ray casting
- Polygon shading
- Global illumination
- Ray tracing
- Monte Carlo methods
- Radiosity methods
Light Source
Surface
N
More on these methods later!
Camera
52The Rendering Pipeline 3-D
Scene graphObject geometry
- Result
- Scene vertices in 3-D view or camera
coordinate system
ModelingTransforms
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
53Rendering Transformations
- Viewing transform
- Rotate translate the world to lie directly in
front of the camera - Typically place camera at origin
- Typically looking down -Z axis
- World coordinates a view coordinates
54The Rendering Pipeline 3-D
Scene graphObject geometry
- Result
- Remove geometry that is out of view
ModelingTransforms
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
55Assignment 2
- Due two and a half weeks from today
- Project description available online
- Well discuss details in class on Monday
56The Rendering Pipeline 3-D
Scene graphObject geometry
- Result
- 2-D screen coordinates of clipped vertices
ModelingTransforms
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
57Rendering Transformations
- Projection transform
- Apply perspective foreshortening
- Distant small the pinhole camera model
- View coordinates a screen coordinates
58Rendering Transformations
- Perspective Camera
- Orthographic Camera
59Rendering 3D Scenes
60Rasterize
- Convert screen coordinates to pixel colors
61Summary
- Geometric primitives
- Points, vectors
- Operators on these primitives
- Dot product, cross product, norm
- The rendering pipeline
- Move models, illuminate, move camera, clip,
project to display, rasterize