Lecture09-VisibleSurfaceDetection (1)
-
Upload
ravi-varma -
Category
Documents
-
view
218 -
download
0
Transcript of Lecture09-VisibleSurfaceDetection (1)
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
1/38
Chapter 9
Somsak Walairacht, Computer Engineering, KMITL
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
2/38
Outline
Classification of Visible-Surface Detection Algorithms Back-Face Detection Depth-Buffer Method A-Buffer Method Scan-Line Method Depth-Sorting Method - ree e o Area-Subdivision Method Octree Methods
- Comparison of Visibility-Detection Methods Wire-Frame Visibility Methods
-
01074410 / 13016218 Computer Graphics 2
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
3/38
Classification of Visible-Surface Detection Algorithms
2 approaches Object-Space Method
Compares objects and parts of objects to each otherwithin the scene
Determine surface as a whole
Image-Space Method
Visibility is decided point by point at each pixel position
Most visibility-surface algorithms use image-spacemethods
01074410 / 13016218 Computer Graphics 3
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
4/38
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
Vview . N > 0
01074410 / 13016218 Computer Graphics 4
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
5/38
Back-Face Detection (2)
Right-handed viewing system If object is converted to projection coordinates and
v , Only consider the z component of the normal vector N
N = (A, B, C) A po ygon is ac ace i = 0
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
6/38
Ex. Back-Face Detection
y xviewyview
B(0,3,0)N(3,2,6)
x+ y+ z - =
x
A(2,0,0), ,
01074410 / 13016218 Computer Graphics 6
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
7/38
Back-Face Detection (3)
Complete visibility test for nonoverlappingconvex polyhedra
For concave polygon, more test must be
carried out to determine whether thereare additional faces that are totall orpartially obscured by other faces
-can be expected to eliminate about half ofthe polygon surfaces in a scene fromfurther visibility tests
01074410 / 13016218 Computer Graphics 7
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
8/38
Depth-Buffer Method
Image-space approach Compares surface depth
scene from each pixel
position on the projection
Also called the z-buffermethod
Depth is measured alongthe z-axis
01074410 / 13016218 Computer Graphics 8
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
9/38
Depth-Buffer Method (2)
2 buffer areas are required 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 lessthan value in the depth buffer, the new value is stored
Algorithm1. Initialize the depth and frame buffer
depthBuff(x, y) = 1.0, frameBuff(x, y) = backgndColor
. For each projected (x, y) pixel, calculate the depth z If z < depthBuff(x, y), compute the surface color
depthBuff(x, y) = z, frameBuff(x, y) = surfColor(x, y)
01074410 / 13016218 Computer Graphics 9
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
10/38
Depth-Buffer Method (3)
Calculate the depth of any point on the plane containing the polygon A surface position (x, y) from plane equation
z = (-Ax-By-D)/C
De th z of x+1z = [-A(x+1)-By-D]/C, z = z-A/C
Depth z of (x-1/m, y-1)z = [-A(x-1/m)-B(y-1)-D]/C, z = z+(A/m+B)/C
Depth z of (x, y-1)z = -Ax-B y-1 -D C, z = z+B C
01074410 / 13016218 Computer Graphics 10
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
11/38
Scan-Line Method
Image-space method Across each scan line, depth calculations are
the view plane at each position
An active list of edges is formed for each scan line Contains onl ed es 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
Process pixel position from left to right At left intersection, flag is on At right intersection, flag is off
01074410 / 13016218 Computer Graphics 11
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
12/38
Scan-Line Method (2)
Scan line 1, active edges:AB,BC,EH,FG
AB-BC, flag S1 on -
Scan line 2, active edges:
AD,EH,BC,FG- ,
EH-BC, flag S1,S2 on Calculate depth After BC, flag S1 off Flag S2 on until FG
Scan line 3 is same as scan line 2 Coherence along scan lines Same active ed es list
01074410 / 13016218 Computer Graphics 12
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
13/38
Scan-Line Method (3)
01074410 / 13016218 Computer Graphics 13
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
14/38
Depth-Sorting Method
Using both image-space and object-spaceoperations
Basic functions
Surfaces are sorted in order of decreasing depth Surface are scan-converted in order, starting with
the surface of greatest depth
s me o s o en re erre o pa n er salgorithm
01074410 / 13016218 Computer Graphics 14
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
15/38
Depth-Sorting Method (2)
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 z
Szmax
S
zmax
zmax
Szmax
zmin
zmin
zmin
zmin
01074410 / 13016218 Computer Graphics 15
x xNo Depth Overlap Depth Overlap
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
16/38
Depth-Sorting Method (3)
Tests for each surface that has a depth overlap with S1. The bounding rectangles (coordinate extents) in xy directions
2. Surface S completely behind the overlapping surface
3. The overlapping surface is completely in front of S
-. overlap
If one of these test is true, no reordering for S
S is scan-converted
01074410 / 13016218 Computer Graphics 16
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
17/38
Depth-Sorting Method (4)
1 2 3
Two surfaces with depth Surface S is completely Overlapping surface Sisoverlap but no overlap in
the x direction
behind the overlapping
surface Scompletely in front of
surface S, but S is not
completely behind S
Two polygon surfaces with
overlapping bounding4
01074410 / 13016218 Computer Graphics 17
rectangles in the xy plane
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
18/38
Depth-Sorting Method (5)
Should all four tests fail for an overlappingsurface S
Interchange surfaces S and S in the sorted list
Surface S extends to a
greater depth, but it
Three surfaces that have
been entered into the
sorted surface list in the
01074410 / 13016218 Computer Graphics 18
order S, S, Sshould be
reordered as S, S, S
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
19/38
BSP- ree Method
Painting surfaces into frame buffer from backto front painters algorithm
Useful when the view reference point
changes, but the objects in a scene are atfixed positions
Visibility testing involves identifying surfaces
e n or n ront o t e part t on ng p ane ateach step of the space subdivision
01074410 / 13016218 Computer Graphics 19
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
20/38
BSP- ree Method
When BSP tree is complete, process the tree from theright nodes to the left nodes
01074410 / 13016218 Computer Graphics 20
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
21/38
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
22/38
BSP- ree Method
25a
5b
front back
1
3 4
5b
2front back
4 15a
01074410 / 13016218 Computer Graphics 22
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
23/38
BSP- ree Method
25a
5b
front back
1
3 2front back
4back
4 15a 5b
01074410 / 13016218 Computer Graphics 23
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
24/38
Area-Subdivision Method
Image-space method Take advantage of coherence, by locating
single surface
By successively dividing the total view-p ane area nto sma er an sma errectangular An easy way is to successively divide the area
n o equa par s a eac s ep Each rectangular contains the projection of
part of a single visible surface
01074410 / 13016218 Computer Graphics 24
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
25/38
Area-Subdivision Method (2)
First, test if the view is sufficientlycomplexYes, subdivide it
est to each smaller areas subdividinif a single surface is still uncertain
Continue until subdivisions are easil
analyzed as belonging to a singlesurface or reached the resolution limit
01074410 / 13016218 Computer Graphics 25
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
26/38
Area-Subdivision Method (3)
Relationship between a surface and an area of the subdividedview plane Surrounding surface
Overlapping surface Partly inside and partly outside the area
Inside surface omp ete y ns e t e area
Outside surface Completely outside the area
01074410 / 13016218 Computer Graphics 26
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
27/38
Area-Subdivision Method (4)
Test for determining surface visibility within arectangular 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,
, Condition 3: An area has one surrounding surface
that obscures all other surfaces
01074410 / 13016218 Computer Graphics 27
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
28/38
Area-Subdivision Method (5)
Condition 1 test by comparing coordinate extents ofeach surface
Condition 3 test by sorting surfaces according to minimum depth from
v ew p ane
Use plane equation to calculate depth values at four verticesof the area for all surrounding, inside, overlapping surfaces
nce a sur ace as een en e as an ou s e orsurrounding, it will remain in that category for allsubdivisions of the area
01074410 / 13016218 Computer Graphics 28
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
29/38
Area-Subdivision Method (6)
As a variation
boundaries instead of dividingthem in half
,subdivisions are required,but more rocessin is
needed to subdivide and toanalyze the relation of
01074410 / 13016218 Computer Graphics 29
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
30/38
Octree Method
When an octree representation is used,visibility testing is done by searching octreenodes in a front-to-back order
Front octants 0,1,2,3 are visible
, , ,
When a color value is encountered, it issaved only if no previously saved value
n y ron co ors are save
01074410 / 13016218 Computer Graphics 30
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
31/38
Octree Method (2)
Visibility testing is carried outwith recursive processing ofoctree nodes and createquadtree representation
Depth-first traversal of the
octree, octant 0 is visitede ore
Completely obscured nodes arenot traversed
Different views of objects,octants are renumbered so that0,1,2,3 are front nodes
01074410 / 13016218 Computer Graphics 31
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
32/38
Ray-Casting Method
Along the line of sight, can determinedwhich objects intersect this line
Method is based on eometric-o ticsmethods, 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
Only follow a ray out from each pixel to thenearest object
01074410 / 13016218 Computer Graphics 32
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
33/38
Comparison of Visibility-Detection Methods
Surfaces are widely distributed Very little depth overlap, few surfaces
Depth-sorting or BSP-tree is most efficient
Few overlaps, small number of surfaces can- ne or area-su v s on s a as way
Several thousand surfaces Scan-line, depth-sorting, or BSP-tree
Few thousand surfaces - Nearly constant with processing time, and independent to number of surfaces
Depth-buffer low performance with simple scenes but high performance for complex scenes
Curved surface representations Ray-casting or ctree
Octree is fast and simple Only integer additions and subtractions, no sorting or intersection calculations
Possible to combine and implement different visible-surface detection methods
01074410 / 13016218 Computer Graphics 33
Parallel processing
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
34/38
Wire-Frame Visibility Methods
Apply depth cueing Displayed intensity of a line is a function of its
distance from the viewer
Hidden edges are eliminated or displayederent y rom t e v s e e ges
Methods are also called visible-line detection
me o s or en- ne e ec on me o s
01074410 / 13016218 Computer Graphics 34
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
35/38
Wire-Frame Surface-VisibilityAlgorithms
Compare edge position with the positions of the surfaces in a
scene Same methods used in line-clipping algorithms
If both projected edge endpoints are behind the surface, edge ishidden
Calculate intersection positions and determine the depth values at
01074410 / 13016218 Computer Graphics 35
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
36/38
Wire-frame Depth-CueingAlgorithm
Displaying visibility information by vary thebrightness of objects as a function of distance
Fdepth = (dmaxd) / (dmaxdmin)where d is the distance of a point form the viewing
osition dmin, dmax can be set to the normalized depth
range 0.0~1.0 ,
depth Nearer points are displayed with higher intensities Points at maximum depth have intensity = 0
01074410 / 13016218 Computer Graphics 36
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
37/38
OpenGL Visibility-DetectionFunctions
01074410 / 13016218 Computer Graphics 37
-
8/10/2019 Lecture09-VisibleSurfaceDetection (1)
38/38
01074410 / 13016218 Computer Graphics 38