Computer Graphics Computer Graphics: Visible Surface Detection Methods Visible Surface Detection Methods
Computer Graphics Computer Graphics: Visible Surface Detection Methods Visible Surface Detection Methods
Outline
Classification of Visible-Surface Detection Algorithms Back-Face Detection Depth-Buffer Method A-Buffer Method Scan-Line Method Depth-Sorting Method BSP-Tree M th d BSP T Method Area-Subdivision Method Octree Methods Ray-Casting Ray Casting Method Comparison of Visibility-Detection Methods Wire-Frame Visibility Methods OpenGL Visibility Detection Functions Visibility-Detection
2
2 approaches
Object-Space Method
Compares objects and parts of objects to each other within the scene Determine su ace as a whole ee e surface oe Visibility is decided point by point at each pixel position on the projection plane
Image-Space Method
Back-Face Detection
A fast and simple object-space method Find the faces on the backs of polyhedral and discard them A point is behind a polygon surface if Ax + By + Cz + D < 0 Back-face test by considering the direction of the normal vector for a polygon surface A polygon is a back face if Vview . N > 0
Right-handed viewing system If object is converted to projection coordinates and viewing direction is parallel to zv axis axis,
yview
xview zview
A(2,0,0) x
6
Complete visibility test for nonoverlapping convex polyhedra For concave polygon, more test must be carried out to determine whether there are additional faces that are totally or y partially obscured by other faces For a general scene, back-face removal back face can be expected to eliminate about half of the polygon surfaces in a scene from further visibility tests
7
Depth-Buffer Method
Image-space approach
Compares surface depth values throughout a scene from each pixel position on the projection plane
A depth buffer
Stores depth values for each (x, y) position Stores the surface-color values for each pixel position
Calculated depth is compared with the stored value, if it is less than value in the depth buffer, the new value is stored Algorithm
1.
2.
For each projected (x, y) pixel, calculate the depth z If z < depthBuff(x, y), compute the surface color
Calculate the depth of any point on the plane containing the polygon A surface position (x, y) from plane equation Depth z of (x+1, y) p ( ,
z = (-Ax-By-D)/C z = [-A(x+1)-By-D]/C, z = z-A/C z = z+(A/m+B)/C z = z+B/C /
z = [-A(x-1/m)-B(y-1)-D]/C,
10
Scan-Line Method
Image-space method Across each scan line, depth calculations are performed to determine which surface is nearest to the view plane at each position An active list of edges is formed for each scan line
Contains only edges that cross the current scan line Sorting in order of increasing x A flag for each surface to indicate whether a position along scan line is inside or outside the surface At left intersection, flag is on At right intersection, flag is off
11
12
13
Depth-Sorting Method
Surfaces are sorted in order of decreasing depth Surface are scan-converted in order, starting with the surface of greatest depth
Compare surfaces whether there are any depth overlaps No overlaps, each surface is processed in depth order until all have been scan-converted If depth overlap is detected, need addition comparisons to determine
z zmax S zmax S zmax zmin zmax zmin No Depth Overlap x S zmin zmin Depth Overlap x
15
The bounding rectangles (coordinate extents) in xy directions do not overlap Surface S completely behind the overlapping surface The overlapping surface is completely in front of S The boundary edge projections on the view plane do not boundary-edge overlap S is the most distant surface S is scan-converted
16
4
01074410 / 13016218 Computer Graphics
Three surfaces that have been entered into the sorted surface list in the order S, S, S should be reordered as S, S, S
18
BSP-Tree Method
Painting surfaces into frame buffer from back to front painters algorithm Useful when the view reference point changes, but the objects in a scene are at fixed positions Visibility testing involves identifying surfaces behind b hi d or in front of the partitioning plane at i f f h ii i l each step of the space subdivision
19
BSP-Tree Method
When BSP tree is complete, process the tree from the right nodes to the left nodes
20
BSP-Tree Method
5 5b 3 1 4
5a
3 1 2 5a 4 5b
21
BSP-Tree Method
5 front 5b 3 1 4 front
5a
3
back
back
4 5b
5a
1
22
BSP-Tree Method
5 front 5b 3 1 4 front
5a
3
back
back
back
5a
5b
23
Area-Subdivision Method
Image-space method Take advantage of coherence, by locating projection areas that represent part of a single surface By successively dividing the total viewplane area into smaller and smaller l i t ll d ll rectangular
An easy way is to successively divide the area into i t 4 equal parts at each step l t t h t
Yes, subdivide it
Test to each smaller areas, subdividing , g if a single surface is still uncertain Continue until subdivisions are easily y analyzed as belonging to a single surface or reached the resolution limit
25
Surrounding surface
Overlapping surface
Completely encloses the area Partly inside and partly outside the area Completely inside the area C l l i id h Completely outside the area
Inside surface
Outside surface
26
Test for determining surface visibility within a rectangular area No further subdivisions if one of the following conditions is true
Condition 1: All surfaces are outside the area Condition 2: An area has only one inside, overlapping, overlapping or surrounding Condition 3: An area has one surrounding surface that obscures all other surfaces
27
Condition 1 test by comparing coordinate extents of each surface Condition 2 usually require intersection tests Condition 3
test by sorting surfaces according to minimum depth from view plane i l Use plane equation to calculate depth values at four vertices of the area for all surrounding, inside, overlapping surfaces
Once a surface has been identified as an outside or O f h b id tifi d t id surrounding, it will remain in that category for all subdivisions of the area
28
As a variation
In general, fewer general subdivisions are required, but more processing is p g needed to subdivide and to analyze the relation of surfaces
29
Octree Method
When an octree representation is used, visibility testing is done by searching octree nodes in a front-to-back order Front octants 0,1,2,3 are visible Rear octants 4 5 6 7 are hidden by the front 4,5,6,7 When a color value is encountered, it is saved only if no previously saved value
30
Visibility testing is carried out with recursive processing of octree nodes and create quadtree representation Depth-first traversal of the octree, octant 0 is visited before b f Completely obscured nodes are not traversed Different views of objects, octants are renumbered so that 0,1,2,3 are front nodes
31
Ray-Casting Method
Along the line of sight, can determined which objects intersect this line Method is based on geometric-optics g p methods, which trace the parts of light rays Trace the light-ray paths backward from the pixels through the scene Effective method for scenes with curved surfaces, particularly, spheres Ray casting is a special case of ray-tracing algorithms
Only follow a ray out from each pixel to the nearest object
32
Depth-sorting or BSP-tree is most efficient Scan-line Scan line or area subdivision is a fast way area-subdivision
low performance with simple scenes but high performance for complex scenes
Ray-casting or O Octree
Only integer additions and subtractions, no sorting or intersection calculations Implemented in hardware Parallel processing
33
Hidden edges are eliminated or displayed differently from th visible edges diff tl f the i ibl d Methods are also called visible-line detection methods or hidden-line detection methods th d hidd li d t ti th d
34
Same methods used in line-clipping algorithms Compare edge and surface depth values
If both projected edge endpoints are behind the surface, edge is hidden Calculate intersection positions and determine the depth values at those intersection points
35
Displaying visibility information by vary the brightness of objects as a function of distance form the viewing position
Fdepth = (dmaxd) / (dmaxdmin) where d is the distance of a point form the viewing p position
dmin, dmax can be set to the normalized depth range 0.0~1.0 Each pixel, its color is multiplied by fdepth(d) pixel
Nearer points are displayed with higher intensities Points at maximum depth have intensity = 0
36
37
End of Chapter 9
38