3d polygon rendering pipeline
TRANSCRIPT
![Page 1: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/1.jpg)
3D Polygon Rendering Pipeline
CS 4810: Graphics
Acknowledgment: slides by Jason Lawrence, Misha Kazhdan, Allison Klein, Tom Funkhouser, Adam Finkelstein and David Dobkin
![Page 2: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/2.jpg)
Road Map for Next Lectures• Leaving ray-tracing
• Moving on to polygon-based renderingoRendering pipeline (today)oClippingoScan conversion & shadingoTexture-mappingoHidden-surface removal
• Polygon-based rendering is what happens on your PC (think NVIDIA, etc.)
![Page 3: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/3.jpg)
3D Polygon Rendering• Many applications use rendering of 3D polygons
with direct illumination
![Page 4: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/4.jpg)
3D Polygon Rendering• Many applications use rendering of 3D polygons
with direct illumination
![Page 5: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/5.jpg)
3D Polygon Rendering• Many applications use rendering of 3D polygons
with direct illumination
![Page 6: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/6.jpg)
Ray Casting Revisited• For each sample …oConstruct ray from eye position through view planeoFind first surface intersected by ray through pixeloCompute color of sample based on surface radiance
More efficient algorithmsutilize spatial coherence!
![Page 7: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/7.jpg)
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.
![Page 8: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/8.jpg)
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
![Page 9: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/9.jpg)
3D Rendering Pipeline (direct illumination)
3D Geometric Primitives
Image
This is a pipelinedsequence of operations to draw a 3D primitive
into a 2D image
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
![Page 10: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/10.jpg)
3D Rendering Pipeline (direct illumination)
Transform from current (local) coordinate systeminto 3D world coordinate system
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
3D Geometric Primitives
Image
![Page 11: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/11.jpg)
Transform into 3D camera coordinate system
3D Rendering Pipeline (for direct illumination)
Transform into 3D world coordinate systemModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
3D Geometric Primitives
Image
![Page 12: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/12.jpg)
Illuminate according to lighting and reflectance
3D Rendering Pipeline (for direct illumination)
Transform into 3D world coordinate systemModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
Transform into 3D camera coordinate system
3D Geometric Primitives
Image
![Page 13: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/13.jpg)
Illuminate according to lighting and reflectance
Transform into 3D camera coordinate system
3D Rendering Pipeline (for direct illumination)
Transform into 3D world coordinate system
Transform into 2D camera coordinate system
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
3D Geometric Primitives
Image
![Page 14: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/14.jpg)
3D Rendering Pipeline (for direct illumination)
Transform into 3D world coordinate system
Clip (parts of) primitives outside camera’s view
Transform into 2D camera coordinate system
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
Illuminate according to lighting and reflectance
Transform into 3D camera coordinate system
3D Geometric Primitives
Image
![Page 15: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/15.jpg)
3D Rendering Pipeline (for direct illumination)
Transform into 3D world coordinate system
Draw pixels (includes texturing, hidden surface, ...)
Clip (parts of) primitives outside camera’s view
Transform into 2D camera coordinate system
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
Illuminate according to lighting and reflectance
Transform into 3D camera coordinate system
3D Geometric Primitives
Image
![Page 16: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/16.jpg)
Transform into 3D camera coordinate system
Illuminate according to lighting and reflectance
Transformations
Transform into 3D world coordinate system
Draw pixels (includes texturing, hidden surface, etc.)
Clip primitives outside camera’s view
Transform into 2D camera coordinate system
ModelingTransformation
CameraTransformation
ProjectionTransformation
Lighting
Clipping
ScanConversion
3D Geometric Primitives
Image
![Page 17: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/17.jpg)
Transformations
ModelingTransformation
CameraTransformation
2D Image Coordinates
ProjectionTransformation
Window-to-ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
Transformations map points from one coordinate system to another
p(x,y,z)
p’(x’,y’)3D World
Coordinates
3D Camera Coordinates
3D Object Coordinates
x
z
y
![Page 18: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/18.jpg)
Viewing Transformations
ModelingTransformation
CameraTransformation
2D Image Coordinates
ProjectionTransformation
Window-to-ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
p(x,y,z)
p’(x’,y’)
Viewing Transformations
![Page 19: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/19.jpg)
Viewing Transformation• Mapping from world to camera coordinatesoEye position maps to originoRight vector maps to X axisoUp vector maps to Y axisoBack vector maps to Z axis
x
-z
y
World
rightup
back
Camera
View plane
![Page 20: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/20.jpg)
Camera Coordinates
Camera right vectormaps to X axis
Camera up vector maps to Y axis
Camera back vectormaps to Z axis(pointing out of page)
• Canonical coordinate systemoConvention is right-handed (looking down -z axis)oConvenient for projection, clipping, etc.
x
y
z
![Page 21: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/21.jpg)
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
?
![Page 22: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/22.jpg)
Finding the Viewing Transformation• Trick: map from camera coordinates to worldoOrigin maps to eye positionoZ axis maps to Back vector oY axis maps to Up vectoroX axis maps to Right vector
• This matrix is T-1 so we invert it to get T … easy!
![Page 23: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/23.jpg)
Finding the Viewing Transformation• Trick: map from camera coordinates to worldoRemember, 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!
![Page 24: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/24.jpg)
Viewing Transformations
ModelingTransformation
CameraTransformation
2D Image Coordinates
ProjectionTransformation
Window-to-ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
p(x,y,z)
p’(x’,y’)
Viewing Transformations
![Page 25: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/25.jpg)
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
![Page 26: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/26.jpg)
Taxonomy of Projections
FvDFH Figure 6.13
![Page 27: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/27.jpg)
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 paralleloPerspective “Projection”:
»Rays converge at a finite point, giving rise to perspective distortion
View Plane View Plane
![Page 28: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/28.jpg)
Taxonomy of Projections
FvDFH Figure 6.13
![Page 29: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/29.jpg)
Parallel Projection
Angel Figure 5.4
• Center of projection is at infinityoDirection of projection (DOP) same for all points
DOP
ViewPlane
![Page 30: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/30.jpg)
Parallel Projection• Parallel lines remain parallel
• Relative proportions of objects preserved
• Angles are not preserved
• Less realistic lookingoFar away objects don’t get smaller
![Page 31: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/31.jpg)
Taxonomy of Projections
FvDFH Figure 6.13
![Page 32: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/32.jpg)
Orthographic Projections
Angel Figure 5.5Top
Side Front
• DOP perpendicular to view plane
Isometric
![Page 33: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/33.jpg)
Orthographic Projections
Angel Figure 5.5Top
Side Front
• DOP perpendicular to view plane
Isometric
• Lines perpendicular to the view plane vanish
• Faces parallel to the view plane are un-distorted.
![Page 34: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/34.jpg)
Taxonomy of Projections
FvDFH Figure 6.13
![Page 35: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/35.jpg)
Cavalier(DOP α = 45o)
Cabinet(DOP α = 63.4o)
1
11
1
11/2
Oblique Projections
H&B Figure 12.21
• DOP not perpendicular to view plane
• φ describes the angle of the projection of the view plane’s normal
• L represents the scale factor applied to the view plane’s normal
![Page 36: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/36.jpg)
Parallel Projection Matrix
H&B Figure 12.21
• General parallel projection transformation:
Cavalier(DOP α = 45o)
Cabinet(DOP α = 63.4o)
1
11
1
11/2
xp
yp
�=
1 0 L cos �
0 1 L sin �
�2
4x
y
z
3
5
![Page 37: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/37.jpg)
Parallel Projection View Volume
H&B Figure 12.30
![Page 38: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/38.jpg)
Taxonomy of Projections
FVFHP Figure 6.10
![Page 39: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/39.jpg)
Perspective “Projection”
Angel Figure 5.9
• Map points onto “view plane” along “projectors” emanating from “center of projection” (COP)
Center ofProjection
View Plane
Projec
tors
![Page 40: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/40.jpg)
Perspective Projection
Angel Figure 5.10
3-Point Perspective
2-Point Perspective
1-Point Perspective
• How many vanishing points?
Number of vanishing points determined by number of axes
parallel to the view plane
x xx
yy y
z
zz
![Page 41: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/41.jpg)
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!
![Page 42: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/42.jpg)
Perspective Projection View Volume
H&B Figure 12.30
ViewPlane
![Page 43: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/43.jpg)
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?
(0,0,0) z
-y
-z
y
D
View Plane
(x0,y0,z0)
![Page 44: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/44.jpg)
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:
(0,0,0) z
-y
-z
y
D(x0,y0,z0)
View Plane
(2x0,2y0,2z0)
![Page 45: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/45.jpg)
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:
(0,0,0) z-z
y
D(x0,y0,z0)
View Plane
(x0, y0, z0)!✓
x0D
z0, y0
D
z0, D
◆
![Page 46: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/46.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
![Page 47: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/47.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
We want to divide by thez coordinate. How do we do that with a 4x4 matrix?
![Page 48: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/48.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
We want to divide by thez coordinate. How do we do that with a 4x4 matrix?
Recall that in homogenouscoordinates:(x, y, z, w) = (x/w, y/w, z/w, 1)
![Page 49: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/49.jpg)
Perspective Projection Matrix
We want to divide by thez coordinate. How do we do that with a 4x4 matrix?
Recall that in homogenouscoordinates:(x, y, z, w) = (x/w, y/w, z/w, 1)
✓xcD
zc,
ycD
zc, D, 1
◆
⇣xc, yc, zc,
zc
D
⌘
• 4x4 matrix representation?
![Page 50: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/50.jpg)
Perspective Projection Matrix
We want to divide by thez coordinate. How do we do that with a 4x4 matrix?
Recall that in homogenouscoordinates:(x, y, z, w) = (x/w, y/w, z/w, 1)
• 4x4 matrix representation?
✓xcD
zc,
ycD
zc, D, 1
◆
⇣xc, yc, zc,
zc
D
⌘
![Page 51: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/51.jpg)
Taxonomy of Projections
FVFHP Figure 6.10
![Page 52: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/52.jpg)
Classical Projections
Angel Figure 5.3
![Page 53: 3D Polygon Rendering Pipeline](https://reader031.vdocuments.site/reader031/viewer/2022021503/58a2d1001a28ab735d8bc8f4/html5/thumbnails/53.jpg)
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