Sei sulla pagina 1di 4

Overview

• Motivation
• Algorithms for HSR
Hidden Surface Removal o Back-face detection
o Depth sort
(or, visibility) o Ray casting
o Scan-line
Adam Finkelstein o Z-buffer
Princeton University o Area subdivision

COS 426, Spring 2003 • Tradeoffs

Motivation 3D Rendering Pipeline


3D Primitives
• Surfaces may be back-facing. 3D Modeling Coordinates
Modeling
Modeling
Transformation
Transformation
• Surfaces may be occluded. 3D World Coordinates
Lighting
Lighting
• Surfaces may overlap in the image plane. 3D World Coordinates
Viewing
Viewing
Transformation Somewhere in here we have to decide
• Surfaces may intersect. Transformation
3D Camera Coordinates which objects are visible, and
Projection
Projection
Transformation
Transformation which objects are hidden.
2D Screen Coordinates
Clipping
Clipping
2D Screen Coordinates
Viewport
Viewport
Transformation
Transformation
2D Image Coordinates
Scan
Scan
Conversion
Conversion
back-facing
polygon 2D Image Coordinates
Image

Overview Visibility algorithms


• Motivation
• Algorithms for HSR
o Back-face detection
o Depth sort
o Ray casting
o Scan-line
o Z-buffer
o Area subdivision

• Tradeoffs

[Sutherland ‘74]

1
Back-face detection 3D Rendering Pipeline
Q: When does this method break down? 3D Primitives
3D Modeling Coordinates
Modeling
Modeling
A: More than one object. Object not closed. Interreflect? Transformation
Transformation Trivial
Trivial Reject
Reject A polygon is backfacing if
3D World Coordinates V•N > 0
Lighting
Lighting
3D World Coordinates
Viewing
Viewing
Transformation
Transformation
3D Camera Coordinates
Projection
Projection
Transformation
Transformation
2D Screen Coordinates N V
Clipping
Clipping back-
back-facing
polygon 2D Screen Coordinates facing
polygon
Viewport
Viewport
Transformation
Transformation
Q: How do we test for back-facing polygons? 2D Image Coordinates
Scan
Scan
Conversion
A: Dot product of the normal and view directions. Conversion
2D Image Coordinates
Image

Depth sort 3D Rendering Pipeline


3D Primitives
3D Modeling Coordinates Depth sort comments
“Painter’s algorithm” Modeling
Modeling
Transformation o O(n log n)
Transformation
o Sort surfaces in order of decreasing maximum depth 3D World Coordinates o Better with frame coherence?
o Scan convert surfaces in back-to-front order Lighting
Lighting
o Implemented in software
3D World Coordinates
Viewing
o Render every polygon
Viewing
Transformation
Transformation o Often use BSP-tree or
3D Camera Coordinates
A Projection
Projection
static list ordering
E D B Transformation
Transformation
2D Screen Coordinates
Clipping
Clipping

eye 2D Screen Coordinates


Depth
Depth sort
sort
Viewport
Viewport
Transformation
Transformation
C 2D Image Coordinates
Scan
Scan
Conversion
Conversion
depth sort Image
2D Image Coordinates

BSP Tree Ray Casting


• Binary space partition with solid cells labeled • Fire a ray for every pixel
o Constructed from polygonal representations o If ray intersects multiple objects, take the closest
o Provides linear-time depth sort for arbitrary view

b 1
1 a
a g 6 2
f c
f 3
e 5 e d 7 c
d d 3
c 4 4 e
b 2 b
5 f
Object Binary Spatial Partition
6 7

Binary Tree

(We’ll come back to this…)


Naylor

2
Ray Casting Pipeline Z-Buffer
• Color & depth of closest object for every pixel
Ray casting comments
o Update only pixels whose depth is closer than in buffer
o O(p log n) for p pixels
3D Primitives o May (or not) use pixel coherence
o Depths are interpolated from vertices, just like colors
3D Modeling Coordinates
Modeling
Modeling o Simple, but generally not used
Transformation
Transformation
3D World Coordinates
Ray
Ray casting
casting
3D World Coordinates &
2D Image Coordinates
Lighting
Lighting

2D Image Coordinates
Image

3D Rendering Pipeline Scan-Line Algorithm


3D Primitives
3D Modeling Coordinates Z-buffer comments • For each scan line, construct spans
Modeling
Modeling
Transformation
Transformation o Polygons rasterized in any order o Sort by depth
3D World Coordinates o Requires lots of memory
Lighting
Lighting
• 1K x 1K x 24bits
3D World Coordinates z=3
• Was expensive, cheap now z=1
Viewing
Viewing z=5
Transformation
Transformation o Subject to aliasing (A-buffer) z=5
3D Camera Coordinates
Projection
Projection
o Commonly in hardware scan line
Transformation
Transformation
2D Screen Coordinates
z=2 z=4
Clipping
Clipping
2D Screen Coordinates
Viewport
Viewport z=5 z=5
Transformation
Transformation
2D Image Coordinates
Scan
Scan z=1.8 z=3.8
Conversion Z-Buffer
Conversion Z-Buffer
example spans
2D Image Coordinates
Image z=5 z=5

3D Rendering Pipeline Area Subdivision


3D Primitives
3D Modeling Coordinates Warnock’s algorithm
Modeling
Modeling
Transformation
Transformation
Scan-line comments o Fill area if:
3D World Coordinates o Fully compute only visible pixels
» All surfaces are outside area, or
Lighting
Lighting o Coherence among along scans
» Only one surface intersects area, or
3D World Coordinates o Commonly in software
Viewing
Viewing
Transformation
» One surface occludes
Transformation
3D Camera Coordinates other surfaces in area
Projection
Projection
Transformation
Transformation o Otherwise, subdivide
2D Screen Coordinates
Clipping
Clipping
2D Screen Coordinates
Viewport
Viewport
Transformation
Transformation
2D Image Coordinates
Scan
Scan
Conversion
Conversion Scan
Scan line
line
2D Image Coordinates
Image

3
3D Rendering Pipeline Conclusions
3D Primitives
3D Modeling Coordinates Algorithms for HSR
Modeling
Modeling
Transformation
Transformation
Area subdivision comments o Back-face detection
3D World Coordinates o Augments scan conversion
o Depth sort
Lighting
Lighting o Polygon coherence
o Ray casting
3D World Coordinates o Commonly in software
Viewing
Viewing
Transformation
o Scan-line
Transformation
3D Camera Coordinates o Z-buffer
Projection
Projection
Transformation
Transformation o Area subdivision
2D Screen Coordinates
Clipping
Clipping • Where in pipeline?
2D Screen Coordinates
Viewport
Viewport
Transformation
Transformation
• Hardware / Software?
2D Image Coordinates
Scan
Scan
Area
• Trends in hardware.
Conversion
Conversion Area subdiv.
subdiv.
2D Image Coordinates
Image

Potrebbero piacerti anche