Introduction OR Need is to eliminate ambiguity
Introduction Wire frame Hidden Line Elimination Hidden Surface Elimination
Introduction Approaches • Image Space Through pixel • Object Space Through primitive
Image Space Approach for ( each pixel in the image ) { determine the object closest to the viewer that is intercepted by the projector through the pixel; draw the pixel in the appropriate color; } Computational effort: np n : number of objects p : number of pixels
Object Space Approach for ( each object in the world ) { determine those parts of the object whose view is unobstructed by other parts of it or any other object; draw those parts in the appropriate color; } Computational effort: n 2 n: number of objects
Floating Horizon Algorithm Surface Function F(x,y,z)=0 y x x z 3 z 5 z 2 z 4 z 1 = constant z 3 z 2 z 1 = constant z z
Floating Horizon Algorithm With z=constant plane closest to the viewpoint, the curve in each plane is generated (for each x coordinate in image space the appropriate y value is found). Projection on z=0 plane y Algorithm: If at any given value of x the y value of the curve in the current plane is z 5 z 4 larger than the y value for any z 3 z 2 previous curve at that x value, z 1 then the curve is visible, otherwise it is hidden. x
Floating Horizon Algorithm Algorithm: If at any given value of x the y value y of the curve in the current plane is larger than the y value or smaller z 5 than the minimum y value for any z 4 z 3 previous curve at that x value, z 2 z 1 then the curve is visible, otherwise it is hidden. x Projection on z=0 plane
Back Face Culling Preprocessing to eliminate faces which are not visible If a surface ’ s normal is pointing away from the eye (viewer), then this is a back face P If n V 0 then backface ⋅ < p n p V
Back Face Culling Conservative algorithm x z
Back Face Culling Conservative algorithm x z
Z-Buffer Algorithm Proposed by Catmull 1974 Simple to implement Z-buffer is like a frame buffer, contains depth (x, y) Z b (x, y) C(x, y) (x, y)
Z-Buffer Algorithm Initialize all d[i,j]=1.0 (max depth), c[i,j]=background color. for (each polygon) for (each pixel in polygon ’ s projection) { Find depth-z of polygon at (x,y) corresponding to pixel (i,j); If z < d[i,j] d[i,j] = z; p[i,j] = color; end }
Z-Buffer Algorithm Computationally Ax By Cz D 0 + + + = At x ( Ax By D ) − + + z , C 0 = ≠ C At x Δ x + ( A ( x Δ x) By D ) − + + + z = 1 C A − z z Δ x − = 1 C A A z z Δ x z ( ∵ Δ x 1) = − = − = 1 C C
Z-Buffer Algorithm Example T T ∞ ∞ ∞ T T T T h he e i h he h he e i e i i m i m i m m ag m ag T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m m ag m ag T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m m ag m ag T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m m ag m ag T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m T T T T ∞ ∞ ∞ ∞ h he h he e i e i i m i m m ag m ag Z-buffer Screen
Z-Buffer Algorithm Example [0,7,5] [6,7,5] T T 5 5 ∞ h h e e i i T T T T 5 5 ∞ ∞ h he h h e i e e i m i i m ag m m T T T T 5 ∞ ∞ ∞ h he h h e i e e i m i i T T T T ∞ ∞ ∞ ∞ h he h h e i e e i m i i m ag m m T T T T ∞ ∞ ∞ ∞ h he h h e i e e i m i i T T T T ∞ ∞ ∞ ∞ h he h h e i e e i m i i m ag m m T T T T ∞ ∞ ∞ ∞ h he h h e i e e i m i i T T T T ∞ ∞ ∞ ∞ h he h h e i e e i m i i m ag m m [0,1,5] Z-buffer
Z-Buffer Algorithm Example [0,6,7] [0,1,2] [5,1,7]
Z-Buffer Algorithm Example T T T T T T T T 5 5 5 5 5 5 5 ∞ h he h h h he h he e i e e e i e i i m i i i m i m T T T T T T T T 5 5 5 5 5 5 ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m m ag m m m ag m ag T T T T T T T T 5 5 5 5 5 ∞ ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m T T T T T T T T 5 5 5 5 ∞ ∞ ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m m ag m m m ag m ag T T T T T T T T 4 5 5 7 ∞ ∞ ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m T T T T T T T T 3 4 5 6 7 ∞ ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m m ag m m m ag m ag T T T T T T T T 2 3 4 5 6 7 ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m T T T T T T T T ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ h he h h h he h he e i e e e i e i i m i i i m i m m ag m m m ag m ag Z-buffer Screen
Z-Buffer Algorithm • Simple method • Complexity Time : nxm buffer k poygons O( nmk ) Space : b depth precision O( nmb )
Painter ’ s Algorithm Depth Sort, List Priority Polygons are painted to the screen in the order of their distance from the viewer (More distant objects are painted first) Screen display
Painter ’ s Algorithm • Sort polygons in order of increasing depth • Draw polygons in sequence, starting from the polygon (surface) of greatest depth • Careful processing of depth • Efficiency depends on sorting algorithm
Painter ’ s Algorithm Z=20 Z=15 Z=10
Painter ’ s Algorithm z P Q P > Q > R Draw first P then Q and then R R Q z Draw first P then Q P > Q P
Painter ’ s Algorithm Cyclic overlapping May require splitting P Q
Binary Space Partitioning (BSP) Space partitioning using planes BSP Tree
Binary Space Partitioning (BSP) For hidden surface elimination: sets a display order P P B B F F BSP Tree
Binary Space Partitioning (BSP) For hidden surface elimination: sets a display order P P B Eye B F F Display order (back to front): BPF BSP Tree
Binary Space Partitioning Example 3 5 front back 5a 2 5b 3 1 4 2 5b 1 4 5a
Binary Space Partitioning Example 3 5 front back 5a 2 5b 3 2 4 5b 1 4 1 5a
Binary Space Partitioning Example 3 5 front back 5a 2 5b 4 3 2 1 4 5b 1 5a
Binary Space Partitioning Example 3 5 front back 5a 2 5b 4 3 2 1 4 5b 1 5a V Display order: 5a 2 1 3 5b 4
Binary Space Partitioning Example 5 back 5 4 2 3 3 1 4 front 1 2
Binary Space Partitioning Example 5 back 5 4 2 3 3 1 4 front 1 V Display order: 5 2 1 3 4 2
Binary Space Partitioning Issues How to select the root polygon? Criteria: Number of split (fragmentation) a. Arbitrary b. Heuristic based with 4-5 polygons and consider which gives the leastnumber of split Static vs Dynamic scene
Area Subdivision Quad tree
Area Subdivision Algorithm Warnock ’ s Algorithm Polygon Area of interest Intersecting Surrounding Contained Disjoint
Area Subdivision Algorithm Consider an area of the projected image If it is easy to decide which polygons are visible in the area, display Else the area is subdivided into smaller areas and the decision is made recursively Divide and Conquer
Area Subdivision Algorithm No Subdivision is required if 1. All the polygons are disjoint: background color in the area. 2. Only one intersecting or only one contained polygon: The area is filled first by background color, then the polygon part contained in the area. 3. Only one surrounding polygon (no contained and intersecting polygons): The area is filled with the color of the surrounding polygon. 4. More than one polygon is intersecting, contained in, or surrounding the area, with surrounding polygon in front: Fill the area with the color of the surrounding polygon.
Warnock ’ s Algorithm Area
Warnock ’ s Algorithm
Warnock ’ s Algorithm
Warnock ’ s Algorithm
Warnock ’ s Algorithm Maximum subdivision: pixel!
Weiler Atherton Algorithm Subdivision along polygon boundaries Clipping!
Weiler Atherton Algorithm • Initial z-sort • Consider front most polygon, clip all polygons to generate Fragments inside polygon and outside polygon • All inside polygons if behind delete from the list • If there is an inside polygon in front (offending), clip the inside list of polygons against this polygon • Process the outside polygon(s)
Weiler Atherton Algorithm B in A B out A A A as clip polygon Inside list: A, B in A Outside list: B out A Display A Process B out A
Weiler Atherton Algorithm y y A B A x B x z z
Weiler Atherton Algorithm A as clip polygon Inside list: A, B in A B out A Outside list: B out A B in A B in A as clip polygon Inside list: B in A, A in B Outside list: B out A, A out B Display B in A
Weiler Atherton Algorithm More polygons with more fragments
Recommend
More recommend