0% found this document useful (0 votes)
129 views53 pages

13 Pipeline

The document describes the 3D polygon rendering pipeline which involves several steps: 1) Geometric primitives are transformed from their local coordinate system to world coordinates and then to camera coordinates. 2) Lighting calculations are performed to illuminate the primitives. 3) Primitives are projected from 3D camera coordinates to 2D screen coordinates. 4) Clipping removes any parts of primitives outside the camera's view.

Uploaded by

nefoy77524
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views53 pages

13 Pipeline

The document describes the 3D polygon rendering pipeline which involves several steps: 1) Geometric primitives are transformed from their local coordinate system to world coordinates and then to camera coordinates. 2) Lighting calculations are performed to illuminate the primitives. 3) Primitives are projected from 3D camera coordinates to 2D screen coordinates. 4) Clipping removes any parts of primitives outside the camera's view.

Uploaded by

nefoy77524
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

3D Polygon Rendering Pipeline

CS 4810: Graphics

Acknowledgment: slides by Jason Lawrence, Misha Kazhdan, Allison Klein, Tom


Funkhouser, Adam Finkelstein and David Dobkin
Road Map for Next Lectures
• Leaving ray-tracing
• Moving on to polygon-based rendering
oRendering pipeline (today)
oClipping
oScan conversion & shading
oTexture-mapping
oHidden-surface removal

• Polygon-based rendering is what happens on your


PC (think NVIDIA, etc.)
3D Polygon Rendering
• Many applications use rendering of 3D polygons
with direct illumination
3D Polygon Rendering
• Many applications use rendering of 3D polygons
with direct illumination
3D Polygon Rendering
• Many applications use rendering of 3D polygons
with direct illumination
Ray Casting Revisited
• For each sample …
oConstruct ray from eye position through view plane
oFind first surface intersected by ray through pixel
oCompute color of sample based on surface radiance

More efficient algorithms


utilize spatial coherence!
3D Polygon Rendering
• Logical inverse of ray casting
• Idea: Instead of sending rays from the camera into the
scene, send rays from the scene into the camera.
3D Polygon Rendering
• Ray casting: pick pixel and figure out what color it
should be based on what object its ray hits
• Polygon rendering: pick polygon and figure out what
pixels it should affect
3D Rendering Pipeline (direct illumination)
3D Geometric Primitives

Modeling
Transformation

Camera
Transformation This is a pipelined
sequence of operations
Lighting
to draw a 3D primitive
into a 2D image
Projection
Transformation

Clipping

Scan
Conversion

Image
3D Rendering Pipeline (direct illumination)
3D Geometric Primitives

Modeling Transform from current (local) coordinate system


Transformation
into 3D world coordinate system
Camera
Transformation

Lighting

Projection
Transformation

Clipping

Scan
Conversion

Image
3D Rendering Pipeline (for direct illumination)
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting

Projection
Transformation

Clipping

Scan
Conversion

Image
3D Rendering Pipeline (for direct illumination)
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting Illuminate according to lighting and reflectance

Projection
Transformation

Clipping

Scan
Conversion

Image
3D Rendering Pipeline (for direct illumination)
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting Illuminate according to lighting and reflectance

Projection Transform into 2D camera coordinate system


Transformation

Clipping

Scan
Conversion

Image
3D Rendering Pipeline (for direct illumination)
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting Illuminate according to lighting and reflectance

Projection Transform into 2D camera coordinate system


Transformation

Clipping Clip (parts of) primitives outside camera’s view

Scan
Conversion

Image
3D Rendering Pipeline (for direct illumination)
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting Illuminate according to lighting and reflectance

Projection Transform into 2D camera coordinate system


Transformation

Clipping Clip (parts of) primitives outside camera’s view

Scan Draw pixels (includes texturing, hidden surface, ...)


Conversion

Image
Transformations
3D Geometric Primitives

Modeling Transform into 3D world coordinate system


Transformation

Camera Transform into 3D camera coordinate system


Transformation

Lighting Illuminate according to lighting and reflectance

Projection Transform into 2D camera coordinate system


Transformation

Clipping Clip primitives outside camera’s view

Scan Draw pixels (includes texturing, hidden surface, etc.)


Conversion

Image
Transformations
p(x,y,z)
3D Object Coordinates Transformations map points from
one coordinate system to another
Modeling
Transformation

3D World Coordinates

Camera 3D Camera
y
Transformation Coordinates

3D Camera Coordinates z 3D Object


Coordinates
Projection x
Transformation

2D Screen Coordinates

Window-to-Viewport
Transformation
3D World
2D Image Coordinates Coordinates
p’(x’,y’)
Viewing Transformations
p(x,y,z)
3D Object Coordinates

Modeling
Transformation

3D World Coordinates

Camera
Transformation

3D Camera Coordinates Viewing Transformations


Projection
Transformation

2D Screen Coordinates

Window-to-Viewport
Transformation

2D Image Coordinates
p’(x’,y’)
Viewing Transformation
• Mapping from world to camera coordinates
oEye position maps to origin
oRight vector maps to X axis
oUp vector maps to Y axis back
oBack vector maps to Z axis up
right
y
View
plane
Camera
-z

x
World
Camera Coordinates
• Canonical coordinate system
oConvention is right-handed (looking down -z axis)
oConvenient for projection, clipping, etc.

Camera up vector
y maps to Y axis

Camera right vector


Camera back vector
maps to X axis
maps to Z axis
(pointing out of page) z x
Finding the Viewing Transformation
• We have the camera (in world coordinates)
• We want T taking objects from world to camera

• Trick: find T-1 taking objects in camera to world

?
Finding the Viewing Transformation
• Trick: map from camera coordinates to world
oOrigin maps to eye position
oZ axis maps to Back vector
oY axis maps to Up vector
oX axis maps to Right vector

• This matrix is T-1 so we invert it to get T … easy!


Finding the Viewing Transformation
• Trick: map from camera coordinates to world
oRemember, with homogeneous coordinates, we divide
through by w values…
oSo if we know actual point in 3D, w = 1
oEasy to find code to invert a matrix

• This matrix is T-1 so we invert it to get T … easy!


Viewing Transformations
p(x,y,z)
3D Object Coordinates

Modeling
Transformation

3D World Coordinates

Camera
Transformation

3D Camera Coordinates Viewing Transformations


Projection
Transformation

2D Screen Coordinates

Window-to-Viewport
Transformation

2D Image Coordinates
p’(x’,y’)
Projection
• General definition:
oA linear transformation of points in n-space to 

m-space (m<n)

• In computer graphics:
oMap 3D camera coordinates to 2D screen coordinates
Taxonomy of Projections

FvDFH Figure 6.13


Projection
• Two general classes of projections, both of which 

shoot rays from the scene, through the view plane:
oParallel Projection:
»Rays converge at a point at infinity and are parallel
oPerspective “Projection”:
»Rays converge at a finite point, giving rise to perspective
distortion

View Plane View Plane


Taxonomy of Projections

FvDFH Figure 6.13


Parallel Projection
• Center of projection is at infinity
oDirection of projection (DOP) same for all points

DOP

View
Plane Angel Figure 5.4
Parallel Projection
• Parallel lines remain parallel
• Relative proportions of objects preserved
• Angles are not preserved
• Less realistic looking
oFar away objects don’t get smaller
Taxonomy of Projections

FvDFH Figure 6.13


Orthographic Projections
• DOP perpendicular to view plane

Side Front

Top Isometric
Angel Figure 5.5
Orthographic Projections
• DOP perpendicular to view plane

• Lines perpendicular to the view plane vanish


Side Front
• Faces parallel to the view plane are un-distorted.

Top Isometric
Angel Figure 5.5
Taxonomy of Projections

FvDFH Figure 6.13


Oblique Projections
• DOP not perpendicular to view plane
1
1
1 1/2

1 1

Cavalier Cabinet
o
(DOP α = 45 ) o
(DOP α = 63.4 )
• φ describes the angle of the projection of the
view plane’s normal
• L represents the scale factor applied to the view
plane’s normal H&B Figure 12.21
Parallel Projection Matrix
• General parallel projection transformation:
1
1
1 1/2

1 1

Cavalier Cabinet
o
(DOP α = 45 ) o
(DOP α = 63.4 )
2 3
  x
xp 1 0 L cos 4 y 5
=
yp 0 1 L sin
z
H&B Figure 12.21
Parallel Projection View Volume

H&B Figure 12.30


Taxonomy of Projections

FVFHP Figure 6.10


Perspective “Projection”
• Map points onto “view plane” along “projectors”
emanating from “center of projection” (COP)

sr
to
ec
oj
Pr
Center of
Projection
View
Plane

Angel Figure 5.9


Perspective Projection
• How many vanishing points?
y y
y

z
z
x x
x
3-Point 2-Point z 1-Point
Perspective Perspective Perspective

Number of vanishing points


determined by number of axes
parallel to the view plane
Angel Figure 5.10
Perspective Projection
• Perspective “projection” is not really a projection
because it is not a linear map from 3D to 2D.
oParallel lines do not remain parallel!
Perspective Projection View Volume

View
Plane

H&B Figure 12.30


Perspective Projection
• What are the coordinates of the point resulting from
projection of (x0,y0,z0) onto the view plane at a
distance of D along the z-axis?
y
(x0,y0,z0)
D
-z (0,0,0) z

View
Plane

-y
Perspective Projection
• Use the fact that for any point (x0,y0,z0) and any
scalar α, the points (x0,y0,z0) and (αx0, αy0, αz0) map
to the same location:

(2x0,2y0,2z0)
y
(x0,y0,z0)
D
-z (0,0,0) z

View
Plane

-y
Perspective Projection
• Use the fact that for any point (x0,y0,z0) and any
scalar α, the points (x0,y0,z0) and (αx0, αy0, αz0) map
to the same location.
• Since we want the position of the point on the line
that intersect the image plane at a distance of D
along the z-axis:
✓ ◆
D D
(x0 , y0 , z0 ) ! x0 , y0 , D y
z0 z0
(x0,y0,z0)
D
-z (0,0,0) z

View Plane
Perspective Projection Matrix
• 4x4 matrix representation?
Perspective Projection Matrix
• 4x4 matrix representation?
We want to divide by the
z coordinate. How do we

do that with a 4x4 matrix?
Perspective Projection Matrix
• 4x4 matrix representation?
We want to divide by the
z coordinate. How do we

do that with a 4x4 matrix?
Recall that in homogenous

coordinates:

(x, y, z, w) = (x/w, y/w, z/w, 1)
Perspective Projection Matrix
• 4x4 matrix representation?
We want to divide by the
z coordinate. How do we

do that with a 4x4 matrix?
Recall that in homogenous

✓ ◆ coordinates:

xc D yc D (x, y, z, w) = (x/w, y/w, z/w, 1)
, , D, 1
zc zc
⇣ zc ⌘
xc , yc , zc ,
D
Perspective Projection Matrix
• 4x4 matrix representation?
We want to divide by the
z coordinate. How do we

do that with a 4x4 matrix?
Recall that in homogenous

✓ ◆ coordinates:

xc D yc D (x, y, z, w) = (x/w, y/w, z/w, 1)
, , D, 1
zc zc
⇣ zc ⌘
xc , yc , zc ,
D
Taxonomy of Projections

FVFHP Figure 6.10


Classical Projections

Angel Figure 5.3


Perspective vs. Parallel
• Perspective projection
+Size varies inversely with distance - looks realistic
– Distance and angles are not preserved
– Only parallel lines that are parallel to the

view plane remain parallel

• Parallel projection
+Good for exact measurements
+Parallel lines remain parallel
+Angles are preserved on faces

parallel to the view plane
– Less realistic looking

You might also like