9' Hidden Surface Removal - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

9' Hidden Surface Removal

Description:

Culling can reduce workload for depth testing but we need to ensure that objects ... However, combining backface culling with more expensive depth-testing is usually ... – PowerPoint PPT presentation

Number of Views:247
Avg rating:3.0/5.0
Slides: 13
Provided by: johndin
Category:

less

Transcript and Presenter's Notes

Title: 9' Hidden Surface Removal


1
9. Hidden Surface Removal
2
Hidden Surface Removal
  • In 3d we must be concerned with whether or not
    objects are obscured by other objects
  • Most objects are opaque so should obscure things
    behind them
  • A.K.A. visible surface detection methods or
    hidden surface elimination methods
  • Related problem Hidden Line Removal

3
Hidden Surface Removal
? ?
4
Backface Culling
  • A quick test for fast elimination. It is not
    always suitable and rarely sufficient but can
    reduce workload considerably
  • we can choose to render only front facing
    polygons

if -90 lt q lt 90 (or cos q gt 0) then the
polygon can be considered front facing and can be
drawn other wise it is culled
u
v
n
5
Backface Culling
  • For all polygons Pi
  • Find Polygon Normal n
  • Find Viewer Direction v
  • IF
  • Then CULL Pi
  • Does not work well for
  • Overlapping front faces due to
  • Multiple objects
  • Concave objects
  • Non-polygonal models
  • Non-closed Objects

6
The Z-buffer Algorithm
  • The most widely used HSR algorithm
  • Relatively easy to implement in hardware or
    software
  • An image-space algorithm which traverses scene
    and operates per polygon rather than per pixels
  • We rasterize polygon by polygon and determine
    which (parts of) polygons get drawn on the screen
  • Relies on a Secondary Buffer called the z-buffer
    or depth buffer
  • Depth buffer has same width and height as the
    frame-buffer
  • Each cell contains the z-value (distance from
    viewer) of the object at that pixel position

7
The Z-buffer Algorithm
  • initialize all depth(x,y) to 0 and refresh(x,y)
    to background colour
  • for each pixel
  • Get current value depth(x,y)
  • Evaluate depth value z
  • if z gt depth(x,y)
  • then
  • depth(x,y) z
  • refresh(x,y) Is (x,y)

Calculate this using shading algorithm/illuminatio
n/fill color/texture
8
Without Hidden surface removal the wrong polygons
can be drawn over
With Backface culling
Alternatively we could cull the front faces to
see inside the solid
9
No hidden surface removal
Backface Culling only correct in some places but
not adequate for objects which have holes, are
non convex or multiple objects
Culling can reduce workload for depth testing but
we need to ensure that objects are proper solids.
This teapot is not quite a proper solid and as a
result the image is incorrect. However, combining
backface culling with more expensive
depth-testing is usually a good practice.
Depth Testing Only
10
The Painters Algorithm
  • Sort polygons according to their z values and
    render from back to front
  • Ends up drawing over the polygons in the back
    (more or less)
  • Problems arise when polygons overlap or are
    allowed to pierce one another
  • Heedless Painters Algorithm sort by farthest
    point and draw in order
  • Depth sort improves on this by splitting up
    overlapping polygons into less ambiguous pieces

11
Depth Sort and Heedless Painter
Heedless Painter generates erroneous result
y
B
A
x
Front view
Far A
z
Far B
B
Ambigous Polygons Split Into two
A
x
Better Depth Sort Result
Top view
12
Scan Line Algorithm
  • Similar in some respects to the z-buffer method
    but handles the image scan-line by scan-line
  • Due to coherency in data, this can be relatively
    efficient.
  • Rasterize all polygon boundaries (edges)
  • Scanning across each scan line we determine the
    colour of each pixel
  • By default colour everything as background
  • if we encounter the edge of one polygon, start
    evaluating polygon colour at each point and
    shade the scanline it accordingly
  • For multiple edges do depth evaluation to see
    which polygon wins
Write a Comment
User Comments (0)
About PowerShow.com