the 3d rasterization pipeline€¦ · perspective vs. parallel • perspective projection + size...
TRANSCRIPT
![Page 1: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/1.jpg)
The 3D Rasterization Pipeline
COS 426
![Page 2: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/2.jpg)
3D Rendering Scenarios• Batch
One image generated with as much quality as possiblefor a particular set of rendering parameters Take as much time as is needed (minutes) Useful for photorealistism, movies, etc.
Interactive Images generated in fraction of a second (<1/10)
with user input, animation, varying camera, etc. Achieve highest quality possible in given time Visualization, games, etc.
![Page 3: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/3.jpg)
3D Polygon Rendering• Many applications use rendering of 3D polygons
with direct illumination
Bungie
![Page 4: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/4.jpg)
3D Polygon Rendering• Many applications use rendering of 3D polygons
with direct illumination
meshview
![Page 5: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/5.jpg)
Ray Casting Revisited• For each sample …
Construct ray from eye position through view plane Find first surface intersected by ray through pixel Compute color of sample based on illumination
![Page 6: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/6.jpg)
3D Polygon Rendering• We can render polygons faster if we take
advantage of spatial coherence
![Page 7: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/7.jpg)
3D Polygon Rendering• How?
![Page 8: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/8.jpg)
3D Polygon Rendering• How?
![Page 9: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/9.jpg)
3D Polygon Rendering• How?
![Page 10: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/10.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
This is a pipelinedsequence of operations to draw 3D primitives
into a 2D image
![Page 11: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/11.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
OpenGL executes steps of 3D rendering pipeline
for each polygon
glBegin(GL_POLYGON);glVertex3f(0.0, 0.0, 0.0);glVertex3f(1.0, 0.0, 0.0);glVertex3f(1.0, 1.0, 1.0);glVertex3f(0.0, 1.0, 1.0);glEnd();
![Page 12: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/12.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
![Page 13: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/13.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Illuminate according to lighting and reflectance
![Page 14: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/14.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Illuminate according to lighting and reflectance
![Page 15: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/15.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Transform into 2D camera coordinate system
Illuminate according to lighting and reflectance
![Page 16: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/16.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Clip primitives outside camera’s view
Transform into 2D camera coordinate system
Illuminate according to lighting and reflectance
![Page 17: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/17.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Clip primitives outside camera’s view
Transform into 2D camera coordinate system
Illuminate according to lighting and reflectance
Transform into image coordinate system
![Page 18: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/18.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Draw pixels (includes texturing, hidden surface, ...)
Clip primitives outside camera’s view
Transform into 2D camera coordinate system
Illuminate according to lighting and reflectance
Transform into image coordinate system
![Page 19: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/19.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
ViewingTransformation
Transform into 3D world coordinate system
Transform into 3D camera coordinate system
Draw pixels (includes texturing, hidden surface, ...)
Clip primitives outside camera’s view
Transform into 2D camera coordinate system
Illuminate according to lighting and reflectance
Transform into image coordinate system
![Page 20: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/20.jpg)
Transformations
ModelingTransformation
ViewingTransformation
2D Image Coordinates
ProjectionTransformation
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 CameraCoordinates
3D ObjectCoordinates
x
z
y
![Page 21: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/21.jpg)
Viewing Transformations
ModelingTransformation
ViewingTransformation
2D Image Coordinates
ProjectionTransformation
ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
p(x,y,z)
p’(x’,y’)
}Viewing Transformations
![Page 22: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/22.jpg)
Viewing Transformation• Mapping from world to camera coordinates
Eye position maps to origin Right vector maps to X axis Up vector maps to Y axis Back vector maps to Z axis
x
y
z
World
rightup
back
Camera
View plane
![Page 23: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/23.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 system Convention is right-handed (looking down -z axis) Convenient for projection, clipping, etc.
x
y
z
![Page 24: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/24.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
wpTcp =
=
wzyx
ponmlkjihgfedcba
wzyx
''''
cpTwp 1−=
?
![Page 25: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/25.jpg)
Finding the Viewing Transformation• Trick: map from camera coordinates to world
Origin maps to eye position Z axis maps to Back vector Y axis maps to Up vector X axis maps to Right vector
• This matrix is T-1 so we invert it to get T … easy!
=
wzyx
EBUREBUREBUREBUR
wzyx
wwww
zzzz
yyyy
xxxx
''''
![Page 26: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/26.jpg)
Viewing Transformations
ModelingTransformation
ViewingTransformation
2D Image Coordinates
ProjectionTransformation
ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
p(x,y,z)
p’(x’,y’)
}Viewing Transformations
![Page 27: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/27.jpg)
Projection• General definition:
Transform points in n-space to m-space (m<n)
• In computer graphics: Map 3D camera coordinates to 2D screen coordinates
![Page 28: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/28.jpg)
Taxonomy of Projections
FVFHP Figure 6.10
![Page 29: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/29.jpg)
Taxonomy of Projections
FVFHP Figure 6.10
![Page 30: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/30.jpg)
Parallel Projection
Angel Figure 5.4
• Center of projection is at infinity Direction of projection (DOP) same for all points
DOP
ViewPlane
![Page 31: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/31.jpg)
Orthographic Projections
Angel Figure 5.5Top Side
Front
• DOP perpendicular to view plane
![Page 32: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/32.jpg)
Parallel Projection Matrix• General parallel projection transformation:
=
1100000000sin100cos01
c
c
c
s
s
s
s
zyx
LL
wzyx
φφ
![Page 33: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/33.jpg)
Parallel Projection View Volume
H&B Figure 12.30
![Page 34: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/34.jpg)
Taxonomy of Projections
FVFHP Figure 6.10
![Page 35: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/35.jpg)
Perspective Projection
Angel Figure 5.9
• Map points onto “view plane” along “projectors” emanating from “center of projection” (COP)
Center ofProjection
View Plane
![Page 36: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/36.jpg)
Perspective Projection• Compute 2D coordinates from 3D coordinates
with similar triangles
(0,0,0) z
-y
-z
y
D
(x,y,z)
ViewPlane
-z
What are the coordinatesof the point resulting fromprojection of (x,y,z) ontothe view plane?
![Page 37: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/37.jpg)
Perspective Projection• Compute 2D coordinates from 3D coordinates
with similar triangles
(0,0,0) z
-y
-z
y
D
(x,y,z)
ViewPlane
-z
(xD/z, yD/z)
![Page 38: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/38.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
=
1????????????????
c
c
c
s
s
s
s
zyx
wzyx
1
//
====
s
s
ccs
ccs
wDz
zDyyzDxx
![Page 39: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/39.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
=
1????????????????
c
c
c
s
s
s
s
zyx
wzyx
1
//
====
s
s
ccs
ccs
wDz
zDyyzDxx
Dzwzzyyxx
c
c
c
c
/''''
====
'/''/''/'
wzzwyywxx
s
s
s
===
![Page 40: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/40.jpg)
Perspective Projection Matrix• 4x4 matrix representation?
1
//
====
s
s
ccs
ccs
wDz
zDyyzDxx
=
10/100010000100001
c
c
c
s
s
s
s
zyx
Dwzyx
Dzwzzyyxx
c
c
c
c
/''''
====
'/''/''/'
wzzwyywxx
s
s
s
===
![Page 41: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/41.jpg)
Perspective Projection View Volume
H&B Figure 12.30
ViewPlane
![Page 42: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/42.jpg)
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
![Page 43: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/43.jpg)
Transformations
ModelingTransformation
ViewingTransformation
2D Image Coordinates
ProjectionTransformation
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 CameraCoordinates
3D ObjectCoordinates
x
z
y
![Page 44: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/44.jpg)
Viewport Transformation• Transform 2D geometric primitives from
screen coordinate system (normalized device coordinates) to image coordinate system (pixels)
ImageScreen
Viewport
Window
![Page 45: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/45.jpg)
Viewport Transformation
vx1 vx2vy1
vy2
wx1 wx2wy1
wy2Window Viewport
Screen Coordinates Image Coordinates
(wx,wy) (vx,vy)
vx = vx1 + (wx - wx1) * (vx2 - vx1) / (wx2 - wx1);vy = vy1 + (wy - wy1) * (vy2 - vy1) / (wy2 - wy1);
• Window-to-viewport mapping
![Page 46: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/46.jpg)
Summary of Transformations
ModelingTransformation
ViewingTransformation
2D Image Coordinates
ProjectionTransformation
ViewportTransformation
3D Object Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
p(x,y,z)
p’(x’,y’)
}Viewing transformations
}Modeling transformation
} Viewport transformation
![Page 47: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/47.jpg)
3D Rendering Pipeline (for direct illumination)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
2D Image Coordinates
3D Modeling Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
2D Screen Coordinates
ViewingTransformation
3D World Coordinates
2D Image Coordinates
![Page 48: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/48.jpg)
Clipping• Avoid drawing parts of primitives outside window
Window defines part of scene being viewed Must draw geometric primitives only inside window
ViewingWindow
![Page 49: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/49.jpg)
Clipping• Avoid drawing parts of primitives outside window
Points Lines Polygons Circles etc.
ViewingWindow
![Page 50: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/50.jpg)
Polygon Clipping• Find the part of a polygon inside the clip window?
Before Clipping
![Page 51: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/51.jpg)
Polygon Clipping• Find the part of a polygon inside the clip window?
After Clipping
![Page 52: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/52.jpg)
Sutherland Hodgeman Clipping• Clip to each window boundary one at a time
![Page 53: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/53.jpg)
Sutherland Hodgeman Clipping• Clip to each window boundary one at a time
![Page 54: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/54.jpg)
Sutherland Hodgeman Clipping• Clip to each window boundary one at a time
![Page 55: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/55.jpg)
Sutherland Hodgeman Clipping• Clip to each window boundary one at a time
![Page 56: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/56.jpg)
Sutherland Hodgeman Clipping• Clip to each window boundary one at a time
![Page 57: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/57.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
![Page 58: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/58.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
![Page 59: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/59.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
![Page 60: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/60.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
![Page 61: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/61.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
P’
![Page 62: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/62.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
P’
![Page 63: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/63.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
P’
![Page 64: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/64.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P5
P4
P3
P’ P’’
![Page 65: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/65.jpg)
Clipping to a Boundary• Do inside test for each point in sequence,
Insert new points when cross window boundary, Remove points outside window boundary
OutsideInside
WindowBoundary
P1
P2
P’ P’’
![Page 66: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/66.jpg)
3D Rendering Pipeline (for direct illumination)
ViewingWindow
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
2D Image Coordinates
3D Modeling Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
2D Screen Coordinates
ViewingTransformation
3D World Coordinates
2D Image Coordinates
![Page 67: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/67.jpg)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
2D Image Coordinates
3D Modeling Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
2D Screen Coordinates
ViewingTransformation
3D World Coordinates
2D Image Coordinates
Standard (aliased)Scan Conversion
P1
P2
P3
3D Rendering Pipeline (for direct illumination)
![Page 68: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/68.jpg)
3D Primitives
ModelingTransformation
ProjectionTransformation
Clipping
Lighting
Image
ViewportTransformation
ScanConversion
2D Image Coordinates
3D Modeling Coordinates
3D World Coordinates
3D Camera Coordinates
2D Screen Coordinates
2D Screen Coordinates
ViewingTransformation
3D World Coordinates
2D Image Coordinates
AntialiasedScan Conversion
P1
P2
P3
3D Rendering Pipeline (for direct illumination)
![Page 69: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/69.jpg)
Scan Conversion• Render an image of a geometric primitive
by setting pixel colors
• Example: Filling the inside of a triangle
P1
P2
P3
void SetPixel(int x, int y, Color rgba)
![Page 70: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/70.jpg)
Triangle Scan Conversion• Properties of a good algorithm
Symmetric Straight edges No cracks between adjacent primitives (Antialiased edges) FAST!
P1
P2
P3
P4
![Page 71: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/71.jpg)
• Color all pixels inside triangle
Simple Algorithm
P1
P2
P3
void ScanTriangle(Triangle T, Color rgba){for each pixel P in bbox(T){
if (Inside(T, P)) SetPixel(P.x, P.y, rgba);
}}
![Page 72: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/72.jpg)
Triangle Sweep-Line Algorithm• Take advantage of spatial coherence
Compute which pixels are inside using horizontal spans Process horizontal spans in scan-line order
• Take advantage of edge linearity Use edge slopes to update coordinates incrementally
dxdy
![Page 73: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/73.jpg)
Triangle Sweep-Line Algorithmvoid ScanTriangle(Triangle T, Color rgba){
for each edge pair {initialize xL, xR;compute dxL/dyL and dxR/dyR;for each scanline at y
for (int x = xL; x <= xR; x++) SetPixel(x, y, rgba);
xL += dxL/dyL;xR += dxR/dyR;
}}
xL xR
dxLdyL
dxRdyR
![Page 74: The 3D Rasterization Pipeline€¦ · Perspective vs. Parallel • Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in](https://reader030.vdocument.in/reader030/viewer/2022040304/5e9ec737efa12b1776022355/html5/thumbnails/74.jpg)
GPU Architecture
GeForce 6 Series Architecture GPU Gems 2, NVIDIA