Visible Surface Detection (V.S.D) : (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)
Visible Surface Detection (V.S.D) : (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)
D)
(Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)
Given a set of 3D objects and a viewing specifications, determine which lines or surfaces of the objects should be visible. A surface might be occluded by other objects or by the same object (self occlusion) Two main approaches:
Image-precision algorithms: determine what is visible at each pixel.
Coherence
Most methods for V.S.D. use coherence features in the surface: Object coherence.
Face coherence.
Edge coherence. Scan-line coherence. Depth coherence. Frame coherence.
Use 2 1D arrays YMIN and YMAX (with 1 entry for each x). When drawing a polyline of constant z, for each x-value, test if above/below YMAX/YMIN (at x location) and update arrays.
40
A B G
30
D
20
10
E F
0 0
old YMAX old YMIN polyline
10
12
30 28 26 25 24 29 34 33 32 34 36 33 30 10 12 14 15 16 15 14 13 12 12 12 13 14 36 34 32 26 20 22 24 16 8 7 A D B C E 6 21 36 F G
Floating Horizon Characteristics: Applied in image space (image precision). Limited to explicit functions only. Exploiting edge coherence. Applicable for free-form surfaces.
Back facing and front facing faces can be identified using the sign of VN In which coordinates N is represented?
V N=[A,B,C]
Three possibilities:
VN> 0 back face VN< 0 front face VN= 0 on line of view
For convex objects, back face detection actually solves the visible surfaces problem. Back face detection is easily applied to convex polyhedral objects. In a general object, a front face can be visible, invisible, or partially visible.
B A
D F H E
Quantitative Visibility
First general hidden surface algorithm, by Appel 1967.
Definition: Every edge has a nonnegative quantitative visible value, Qv, which corresponds to the number of times the edge is obscured. If Qv=0 the edge is visible.
Definition: An active edge is a silhouette edge, i.e, it is shared by back and front faces.
Observations: The visibility of an edge can be changed only where it intersects another active edge in the viewing plane. If the edge does not intersect any active edge, its visibility is homogeneous.
Algorithm:
Select a single point on line and test how many polygons obscure it. Increment/decrement Qv any time the line intersects an active edge, and the intersection is inside the view triangle. Propagate from the end point to a neighboring line. Fill the resulting polygons appropriately.
Answer: Edges of a polygon are described clockwise when viewing the object from outside (so the face is to the right). We test the configuration of the line direction with the direction of intersecting edge describing the front face.
Leave a face - decrease Qv
MM MM MM MM MM MM MM MM
5 5 5 5 5 5 5
5 5 5 5 5 5
5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 M MM MM MM MM MM
5 M MM MM MM MM MM MM MM
5 5 5 5 5 M MM MM MM MM MM
5 M MM MM MM MM MM MM MM
5 7 6 5 4 3 2 0
5 5 5 5 5 5 5 5 7 5 5 5 6 7 5 0 5 6 7 0 4 5 6 7 3 4 5 6 0 0 0 0
5 5 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 0 0
5 5 5 5 5 5 5 M 5 5 5 5 5 5 MM 5 5 5 5 5 M MM 5 5 5 5 MM MM 4 5 5 M MM MM 3 4MM MM MM 2 3 4 M MM MM MMMM MM MM
Mistake
Algorithm:
Initialize the z-buffer and the frame-buffer: depth(x,y)=MAX_Z ; I(x,y)=Ibackground Calculate the depth Z for each (x,y) position on any surface: If z<depth(x,y), then set depth(x,y)=z ; I(x,y)=Isurf(x,y)
For polygon surfaces, the depth-buffer method is very easy to implement using polygon scan line conversion, and exploiting face coherence and scan-line coherence :
Z = -(Ax+By+D)/C Along scan lines
Z'= -(A(x+1)+By+D)/C=Z-A/C
Depth-Buffer Characteristics
Implemented in the image space. Very common in hardware due its simplicity (SGI's for example). 32 bits per pixel for Z is common. Advantages: Simple and easy to implement. Disadvantages:
Question: What if polygons are not Z constant? Observation: Given two polygons P and Q, an order may be determined between them, if at least one of the following holds:
1. Z values of P and Q do not overlap. 2. The bounding rectangle in the x,y plane for P and Q do not overlap. 3. P is totally on one side of Qs plane. 4. Q is totally on one side of Ps plane. 5. The bounding rectangles of Q and P do not intersect in the projection plane.
x
1
Z
2
Z
3 and 4
If all the above conditions do not hold, P and Q may be split along intersection edge into two smaller polygons.
x x
A
B B
Tests 3 and 4 in Depth Sort technique can be exploited efficiently: Let Lp be the plane P lies in: The 3D space may be divided into the following three groups:
Polygons in front of Lp.
Polygons behind Lp. Polygons intersecting Lp.
Polygons in the third class are split, and classified into the first two. As a result of the subdivision with respect to Lp:
The polygons behind Lp cannot obscure P, so we can draw them first. P cannot obscure the polygons in front of Lp so we can draw P second. Finally we draw the polygons in front of P.
Display:
Traverse the BSP tree back to front, drawing polygons in the order they are encountered in the traversal.
1 3
1 3 6
1 3
7
4
6 5 4
BSP Properties: The BSP tree is view independent! The BSP tree is constructed using the geometry of the object only. The tree can be used for hidden surface removal at an arbitrary direction. BSP = Object-precision alg.
Surrounding
Intersecting
Contained
disjoint
If all polygons are disjoint from the area, fill area with background color. Only one intersecting or contained polygon: First fill with background color, then scan convert polygon.
When the resolution of the image is reached, polygons are sorted by their Zvalues at the center of the pixel, and the color of the closest polygon is used.