Page 1

Graphics

Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실

cgvr.korea.ac.kr

1

Graphics Lab @ Korea University


3D Rendering Pipeline 3D Primitives

CGVR

3D Modeling Coordinates

Model Model Transformation Transformation 3D World Coordinates Lighting Lighting 3D World Coordinates Viewing Viewing Transformation Transformation 3D Viewing Coordinates Projection Projection Transformation Transformation 2D Projection Coordinates Clipping Clipping 2D Projection Coordinates Viewport Viewport Transformation Transformation 2D Device Coordinates

Hidden Surface Removal

Scan Scan Conversion Conversion Image

2D Device Coordinates Graphics Lab @ Korea University


Hidden Surface Removal  

Motivation Algorithms for HSR      

CGVR

Back-face detection Painter’s algorithm Ray casting Scan-line Z-buffer Area subdivision

Tradeoffs

Graphics Lab @ Korea University


Motivation 

CGVR

Surfaces may be Back-Facing: Back-Facing Polygon Viewer

Surfaces may be Occluding:

Viewer

Occluding Polygon

Occluded Polygon Graphics Lab @ Korea University


Motivation 

CGVR

Surfaces may be Overlapping:

Viewer 

Surfaces may be Intersecting:

Viewer Graphics Lab @ Korea University


Algorithms      

CGVR

Back-Face Detection Painter’s Algorithm Ray Casting Scan-Line Z-Buffer Area Subdivision

Graphics Lab @ Korea University


Back-Face Detection ď Ž

CGVR

Do not Render any Surface Oriented Away from Viewer Back-Facing Polygon

V Viewer Polygon is back-facing to the viewer if V•N > 0

N

3D Primitives Model Model Transformation Transformation Lighting Lighting Viewing Viewing Transformation Transformation

Graphics Lab @ Korea University


Depth Sort 

CGVR

Painter’s Algorithm:  

Sort surfaces in order of decreasing maximum depth Scan convert surfaces in order starting with ones of greatest depth, reordering as necessary based on overlaps A

D

Viewer

C View Plane

B Depth Sort

E Viewport Viewport Transformation Transformation Scan Scan Conversion Conversion Image Graphics Lab @ Korea University


Depth Sort 

CGVR

Comments     

O(nlogn) Intersecting polygons must be subdivided Sort order has lots of frame-to-frame coherence during walkthroughs Must fully compute every pixel for every polygon Used most often with BSP or static list-ordering

Graphics Lab @ Korea University


Ray Casting ď Ž

CGVR

Algorithm: ď Ž

Cast ray from viewpoint through each pixel to find front-most surface

A

D

E

3D Primitives Model Model Transformation Transformation

Viewer

C View Plane

B

Lighting Lighting Viewing Viewing Transformation Transformation

Graphics Lab @ Korea University


Ray Casting 

CGVR

Comments   

O(plogn) for p pixels May (or may not) utilize pixel-to-pixel coherence Conceptually simple, but not generally used

Graphics Lab @ Korea University


Z-Buffer 

CGVR

Algorithm:  

Store color and depth of closest surface for each pixel in frame buffer As scan convert, update only pixels whose (interpolated) depth is closer than the depth stored in the frame buffer z=3

z=1

z=5 z=2

z=4

z=5

Viewport Viewport Transformation Transformation Scan Scan Conversion Conversion

z=5

Image Graphics Lab @ Korea University


Z-Buffer 

CGVR

Comments    

Polygons can be rasterized in any order Requires lots of memory Requires per pixel processing, subject to aliasing (Abuffer) Commonly implemented in hardware

Graphics Lab @ Korea University


Scan-Line 

CGVR

Algorithm: 

For each scan line, construct spans and sort by depth z=3

z=1

z=5

Scan Line z=2

z=4

z=5

Example: Spans

z=1.8

z=5 z=3.8

Viewport Viewport Transformation Transformation Scan Scan Conversion Conversion Image

z=5

z=5 Graphics Lab @ Korea University


Scan-Line 

CGVR

Comments   

Fully compute only front-most pixels Coherence along scan lines Commonly implemented in software

Graphics Lab @ Korea University


Area Subdivision 

CGVR

Algorithm: 

Fill area if:   

All surfaces are outside Only one surface intersects One surface occludes other surfaces within area.

Otherwise, subdivide

Graphics Lab @ Korea University


Conclusion 

Hidden surface algorithms      

Back-face detection Depth sort Ray casting Z-buffer Scan-line Area subdivision

Hardware 

CGVR

Z-buffer

Software  

Depth sort Scan-line Graphics Lab @ Korea University

12hidden  

??????????????? cgvr.korea.ac.kr Graphics Lab @ Korea University Graphics Lab @ Korea University 1

Advertisement