This document discusses various visible surface detection methods in computer graphics. It describes object-space methods like back-face detection that compare object surfaces, and image-space methods like depth buffering that determine visibility point-by-point. Specific algorithms covered include depth buffering, scan-line, depth sorting, BSP trees, ray casting, and methods for curved and wireframe surfaces. It also provides examples and discusses functions for implementing visibility detection in OpenGL.
2. Learning Objectives
Classification of Visible Surface Detection Algorithms
Back-Face Detection
Depth-Buffer Method
A Buffer Method
Scan-Line Method
Depth-Sorting Method
BSP – TREE Method
Area Sub Division Method
Octree Method
Ray Casting Method
Curved Surfaces
Wire-Frame Visibility Methods
Visibility Detection Functions
3. Visible Surface Detection
A major consideration in the generatation of
realistic graphics is determining what is visible
within a scene from a chosen viewing position
Algorithms to detect visible objects are referred
to as visible-surface detection methods
4. Classification of Visible Surface
Detection Algorithms
Object-space methods
Compares objects and parts of object to each other
within the scene definition to determine which
surfaces should be marked as visible
Image-space methods
Visibility is decided point by point at each pixel
position
5. Back-Face Detection
A fast and simple object-space method for
locating back faces
A point (x,y,z) is “inside” a polygon surface with
plane parameters A, B, C, D if :
Ax + By + Cz + D < 0
When an inside point is along the line of sight to
the surface, the polygon must be a back face and
so cannot be seen
6. Back-Face Detection
The test is simplified by considering the normal vector
N to the polygon and the viewing vector V
This is back face if
V · N > 0
7. Back-Face Detection …
V.N = Vz . C > 0
In right handed viewing system, the polygon is a
back face
if C <= 0
8. Depth(Z) Buffer Method
A commonly used image-space approach
Each surface is processed separately, one point
at a time
Also called the z-buffer method
It is generally hardware implemented
10. Depth Buffer Method
Two buffers are needed
Depth buffer (distance information)
Frame buffer (intensity/color information)
11. Depth Buffer Method
Depth-Buffer Algorithm
for all (x,y)
depthBuff(x,y) = 1.0, frameBuff(x,y)=backgndcolor
for each polygon P
for each position (x,y) on polygon P
calculate depth z
if z < depthBuff(x,y) then
depthBuff(x,y) =z
frameBuff(x,y)=surfColor(x,y)
12. Depth Calculation
Calculate the z-value on the plane
Incremental calculation
C
DByAx
zDCzByAx
0
C
B
z
C
DyBAx
z
C
A
z
C
DByxA
z
yxyx
yxyx
),()1,(
),(),1(
)1(
)1(
),(positionofdepththe:),( yxz yx
13. Accumulation Buffer (A-Buffer)
An extension of the depth-buffer for dealing
with anti-aliasing, area-averaging, transparency,
and translucency
The depth-buffer method identifies only one
visible surface at each pixel position
Cannot accumulate color values for more than one
transparent and translucent surfaces
Even more memory intensive
Widely used for high quality rendering
14. Accumulation Buffer (A-Buffer)
Each position in the A-buffer has two
fields
Depth field: Stores a depth value
Surface data field
RGB intensity components
Opacity parameter (percent of transparency)
Depth
Percent of area coverage
Surface identifier
15. Scan-Line Method
Image space method
Extension of scan-line algorithm for polygon
filling
As each scan line is processed, all polygon
surface projections intersecting that line are
examined to determine which are visible
17. Scan-Line Method (cont…)
Pixel positions across each scan-line are
processed from left to right
At the left intersection with a surface the surface
flag is turned on (S1flag, S2 flag – on/off)
At the right intersection point the flag is turned
off
We only need to perform depth calculations
when more than one surface has its flag turned on
at a certain scan-line position
18. Scan-Line Method (cont…)
Two important tables are maintained:
The edge table
The surface facet table
The edge table contains:
Coordinate end points of reach line in the scene
The inverse slope of each line
Pointers into the surface facet table to connect
edges to surfaces
19. Scan-Line Method (cont…)
The surface facet tables contains:
The plane coefficients
Surface material properties
Other surface data
Maybe pointers into the edge table
20. Scan-Line Method Limitations
The scan-line method runs into trouble when
surfaces cut through each other or otherwise
cyclically overlap
Such surfaces need to be divided
ImagestakenfromHearn&Baker,“ComputerGraphicswithOpenGL”(2004)
22. Depth-Sorting Method
Both image-space and object-space operations
Also called painter’s algorithm
Surfaces sorted in order of increasing depth
Surfaces scan-converted in order, starting with the surface of greatest
depth
B behind A as seen by viewer Fill B then A
23. Depth Sorting
We make the following tests for each polygon that has
a depth overlap with S
If any one of these tests is true, no reordering is
necessary for S and the polygon being tested
Polygon S is completely behind the overlapping surface
relative to the viewing position
The overlapping polygon is completely in front of S relative
to the viewing position
The boundary-edge projections of the two polygons onto the
view plane do not overlap
27. BSP Trees
Binary space partitioning is an efficient method
for determining object visibility
Paint surfaces into the frame buffer from back
to front
Particularly useful when the view reference point
changes, but the objects are at fixed positions
28. BSP Tree Construction
1. Choose a polygon T and compute the equation of the plane it
defines
2. Test all the vertices of all the other polygons to determine if
they are in front of, behind, or in the same plane as T.
3. If the plane intersects a polygon, divide the polygon at the
plane
4. Polygons are placed into a binary search three with T as the
root
5. Call the procedure recursively on the left and right subtree
30. Area Subdivision
Four possible relationships between polygon surfaces
and a rectangular section of the viewing plane
Terminating criteria
Case 1: An area has no inside, overlapping, or surrounding
surfaces (all surfaces are ourside the area)
Case 2: An area has only one inside, overlapping or
surrounding surfaces
Case 3: An area has one surrounding surface that obscures all
32. Ray Casting
We consider the line of sight
from the a pixel position through
the scene
Useful for volume data
Ray casting is a special case of
ray tracing that we will study
later
34. Curved Surfaces
Surfaces are described using special curves;
representations for curves generalize to representations
for surfaces
Explicit form:
Implicit form:
Parametric form:
),( yxfz
0),,( zyxf
))(),(),((),,( tztytxzyx p
35. Surface contour plots
Y = f(x,z)
Identify visible curve section
maintain ymin to y max values previously
calculated for the pixel x
Increment x by 1 and find y, if y in the range, y
not visible. Otherwise visible
Similarlly find YZ plane and XZ plane to find
visible area
36. Display all object edges – difficult to determine front and back
Depth cueing – displayed intensity of a line is a function of its
distance from the viewer
Wire-Frame Visibility Methods
39. Wire-Frame Depth Cueing
Vary the brightness of objects in a scene as a function of
distance from the viewing position
minmax
max
)(
dd
dd
dfdepth
Multiply each pixel color by:
Where d is the distance of a point
from the viewing position
40. Visibility Detection Functions
Back-face removal:
glEnable(GL_CULL_FACE);
glCullFace(mode);
GL_BACK, GL_FRONT, GL_FRONT_AND_BACK
glDisable(GL_CULL_FACE);
default
GL_BACK is default. Sometimes we want to see the back faces,
for example if we are in a room we can use GL_FRONT
41. Visibility Detection Functions
Depth-buffer functions:
Request depth buffer when initializing:
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
Clear depth buffer each time a new frame is displayed:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
OpenGL depth-buffer visibility-detection routines can be
activated with
glEnable(GL_DEPTH_TEST);
and deactivated with
glDisable(GL_DEPTH_TEST);
43. Visibility Detection Functions
Depth cueing:
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_LINEAR);
This applies the linear depth function to object colors using
dmin=0.0 and dmax=1.0. We can set different values for dmin and
dmax with the following function calls
glFogf(GL_FOG_START, minDepth);
glFogf(GL_FOG_END, maxDepth);
Hidden line hidden surface removal(HLHSR) FUNCTION
setHLHSRidentifier(visibilityfunctionIndex)