download

Graphics Pipeline
Rendering Operations:
Clipping, Rasterization, & Hidden
Surface Removal
Adapted from 3D Computer Graphics by Alan Watt
Third Edition, Pearson Education Limited, 2000
1
Graphics Pipeline
„
„
„
3D scene mapped as a
two-dimensional surface.
Find the color of the pixel.
Two process
„
Geometric
„
„
CPU intensive
Algorithmic – Rendering
„
Video Card - GPU
3D Space
2D Space
2
Graphics Pipeline
„
Object Space
„
„
„
World Space
„
„
„
„
„
„
World Coordinate - geometric
Compose Scene - geometric
Define View - geometric
Define Lighting - geometric
Radiosity & Photon Mapping –
rendering
Modeling
Transformation
View
Transformation
Projection
Transformation
World Space
View Space
View Space
„
„
„
„
Local Coordinates - geometric
Object Definition - geometric
Local Space
View volume - geometric
Cull - geometric
Clip to View Volume –
geometric/rendering
3D Screen Space
3D Screen Space
„
„
„
Rasterization – rendering
Hidden surface removal - rendering
Shading – rendering
Display or Image Space
3
Rendering Operations
1.
Clipping to the View Volume
„
2.
Rasterization
„
3.
Finding the set of pixels in which a polygon projects.
Hidden Surface Removal
„
4.
Determining what portion of a polygon that crosses the
View Volume should be rendered.
Determines which polygons will not be seen.
Shading
„
Interpolating the value of the pixels within a polygon.
4
Clipping to the View Volume
„
„
Cull then Clip.
Geometric Operation
„
Cull to View Volume
„
„
„
„
View Space – View
Coordinates
Determine if polygons are
outside or inside the View
Volume
Determine if polygons
straddle the View Volume
Discard as many polygons as
possible
5
Projection Transformation
„
Geometric Operation
Transforming scene
geometry from View Space
into 3D Screen Space.
View Space - Perspective
Cube
Projection
Transformation
„
3D Screen Space - Orthographic
Clip rectangle
Transformed
Cube
6
Clipping to the View Volume
Clip boundary
„
Each polygon is evaluated
against the clipping boundary
of the View Volume and
clipped accordingly.
View
Inside S1
Space - Perspective
F1
S2
F1
I1
Cube
Polygon
F2
Outside
Polygon
View
Transformation
Clip rectangle
Case 1
Case 2
F4
F1
I2
I2
I1
I1
F3
S4
S3
Bottom Clip
Figure 1
Left Clip
Right Clip
Top Clip
Case 3
Sutherland-Hodgman clipper
F4
3D Screen
Space - Orthographic
F1
F1
Transformed
I1
Cube
Case 4
Figure 2
Case 5
7
3D Screen Space
„
Geometric Operations
„
„
Point projection onto
Screen Space
Geometric Transformation
Figure 1 - Geometric Transformation
a) View Space
b) 3d Screen Space
Object Space
World Space
View Space
3D Screen Space
Display or Image Space
Figure 2 – Projection of object’s
vertices into 3d Screen Space
8
Rasterization
„
Rasterizing edges
„
Generate a linear set of pixels with no gaps
Raster Grid
Figure 1b
1a – Projection of edges
vertices
into 3D Screen Space.
Raster Grid
9
Rasterization
„
„
„
„
„
„
3D Screen Space
Rasterization
Find pixel coordinates of interior points
Scan line Procedure
“Filling the polygon”
Assign a value based on shading
scheme
Object Space
World Space
View Space
3D Screen Space
Display or Image Space
Raster Grid
y
Scan line plane
Scan line
scan lines
z
3D Screen Space
Figure 1 - Raster Grid / Scan Line
x
Figure 2 – Scan Line Plane
10
Rasterization
„
„
„
„
„
„
3D Screen Space
Rasterization
Find pixel coordinates of interior points
Scan line Procedure
“Filling the polygon”
Assign a value based on shading
scheme
Object Space
World Space
View Space
3D Screen Space
Display or Image Space
Raster Grid
y
Scan line plane
Scan line
scan lines
z
3D Screen Space
Figure 1 - Raster Grid / Scan Line
x
Figure 2 – Scan Line Plane
11
Hidden Surface Removal (HSR)
„
Hidden Surface Removal (HSR)
„
„
„
„
Hidden Surface Determination
Visible Surface Determination
Hidden Line Removal (HLR).
Determining which surface are visible .
12
Hidden Surface Removal
„
Geometric Operations
„
Tessellation
„
„
Culling
„
„
„
Converting all geometry to
triangles.
View Volume - surfaces outside
of the view volume are culled.
Backface - Orientation of Surface
Normal to the Camera.
Geometric Transformation
„
Patch
Poly
Three sided
Polygon
Converting Geometry from View
Space to Orthographic 3D Screen
Space.
13
Hidden Surface Removal
„
Geometric Operations
„
Tessellation
„
„
Culling
„
„
„
Converting all geometry to
triangles.
View Volume - surfaces outside
of the view volume are culled.
Backface - Orientation of Surface
Normal to the Camera.
Geometric Transformation
„
Converting Geometry from View
Space to Orthographic 3D Screen
Space.
Back Face Culling
Culling to the View Volume
14
Hidden Surface Removal
„
Geometric Operations
„
Tessellation
„
„
Culling
„
„
„
Converting all geometry to
triangles.
View Volume - surfaces outside
of the view volume are culled.
Backface - Orientation of Surface
Normal to the Camera.
Geometric Transformation
„
Converting Geometry from View
Space to Orthographic 3D Screen
Space.
Transformed
Cube
Cube
View Space - Perspective
3D Screen Space - Orthographic
15
Hidden Surface Removal
„
„
„
Z-Buffer
the depth of a generated pixel
z coordinate is stored in a
buffer (z-buffer).
Two-dimensional X-Y array
Excerpted from Wikipedia, http://en.wikipedia.org/wiki/Z-buffering
16
Hidden Surface Removal (HSR)
„
Polygon-by-Polygon or Painter’s Algorithm
„
Scanline Renderer
17
Hidden Surface Removal (HSR)
„
Polygon-by-Polygon or Painter’s Algorithm
„
„
„
„
„
Simple to implement
No upper limit on scene complexity
Overlapping of polygons are difficult to render.
Inefficient
Hidden Line Removal - Z-buffer – memory
intensive
Wikipedia, http://en.wikipedia.org/wiki/Image:Painter%27s_algorithm.png
18
Hidden Surface Removal (HSR)
„
y
Scan Line /w Z-buffer
„
„
„
„
„
„
„
Most commonly used
Polygons rendered row by
row.
Polygons sorted based on
Z-depth.
HLR - Z-buffer, scan-line zbuffer, spanning scan line
algorithm.
Scan line order – efficient
for anti-aliasing.
Not as memory intensive
Limits complexity of scene
Scan line
z
3D Screen Space
Scan Line Rendering
x
Excerpted from Wikipedia: http://en.wikipedia.org/wiki/Scanline_rendering
19
Hidden Surface Removal
„
„
Advantage – Simplicity
„
„
„
„
„
Dedicated Z-Buffer memory
Unseen polygons are rendered
Z-depth precision
Scan line
Scanline algorithm
„
Advantages
„
„
„
Machine efficient
Needs limited memory
z
Disadvantages
„
„
Fetch individual polygons in any order
No upward limit of polygons (scene complexity)
Disadvantage – Memory
„
„
y
Z-buffer algorithm
Limited scene complexity
3D Screen Space
De facto standard - Scanline Z-buffer
„
„
Scan-lined – algorithm intensive – Screen Space
Z-Buffered – memory intensive – Object Space
Scan Line Rendering
x
20
Graphics Pipeline
„
Object Space
„
„
„
World Space
„
„
„
„
„
„
World Coordinate - geometric
Compose Scene - geometric
Define View - geometric
Define Lighting - geometric
Radiosity & Photon Mapping –
rendering
Modeling
Transformation
View
Transformation
Projection
Transformation
World Space
View Space
View Space
„
„
„
„
Local Coordinates - geometric
Object Definition - geometric
Local Space
View volume - geometric
Cull - geometric
Clip to 3D – geometric/rendering
3D Screen Space
3D Screen Space
„
„
„
Rasterization – rendering
Hidden surface removal - rendering
Shading – rendering
Display or Image Space
21
END
22