Download presentation

Presentation is loading. Please wait.

1
6/14/2015©Zachary Wartell Visible Surface Detection Copyright 2006, Zachary Wartell at University of North Carolina. All rights reserved. Revision 1.3 Textbook: Chapter 9

2
6/14/2015©Zachary Wartell Back-Face Culling Used to remove unseen polygons from convex, closed polyhedron (Cube, Sphere) Does not completely solve hidden surface problem since one polyhedron may obscure another, Larry F. Hodges, Drew Kessler

3
6/14/2015©Zachary Wartell Back Face Culling point ( x,y,z ) is behind planar surface iff: Ax+By+Cz+D<0 planar surface, S, faces away from PRP = PRP behind S Alternatively test for: z view N > 0 If we compute N after transforming to projection coordinates (so projectors are all perpendicular to view window), just test z N PRP View Window PRP View Window N=( A,B,C) y view x view z view PRP= N y view x view z view

4
6/14/2015©Zachary Wartell Depth-Buffer Method Recall Slide: ITCS 4120-3D Viewing.ppt # 51-53, “3D→3D collineation on cube” ITCS 4120-3D Viewing.ppt

5
6/14/2015©Zachary Wartell Depth-Buffer Algorithm 1.Initialize depth buffer and frame buffer for all pixels ( x,y ) depthBuffer(x,y) = 1.0; frameBuffer(x,y)=BackgroundColor 2.Process each polygon face, F, in scene –For each projected pixel, P, at location ( x,y ) in F, calculate the depth z –If z < depthBuffer(x,y), compute surface color, C, at the pixel P, so set: depthBuffer(x,y) = z ; frameBuffer(x,y)=C Note: After all surfaces are processed, depth buffer contains depth for visible surfaces and frame buffer contains corresponding color values for those surfaces

6
6/14/2015©Zachary Wartell (x r,y r, z r ) (x l,y l, z l ) (x,y, z) Computing z After M 3dscr←{ obliquepers,oblique} you have vertices: {( x i,y i,z i )} Generally to compute z: Incremental in x: Incremental in y:

7
6/14/2015©Zachary Wartell A-Buffer Method accumulation buffer – buffer accumulates multiple pieces of information for each pixel in addition to depth for transparency or anti-aliasing (high-end movies, etc.). A-buffer element stores: –Depth Field : real-number –Surface Data Field (SDF): stores surface data or pointer When Depth >= 0: -real-number is depth of surface at pixel -SDF is surface color and pixel coverage percentage depth ≥ 0 RGB & Other Info Pixel 44% 48%

8
6/14/2015©Zachary Wartell When Depth < 0: -SDF is pointer to linked list of elements that store: -RGB intensity -opacity -depth -pixel coverage percentage -surface ID -other surface rendering parameters A-Buffer Method Depth < 0 RGB & Other Info RGB & Other Info Surface 1 Surface 2

9
6/14/2015©Zachary Wartell Scan-Line Method Unlike z-buffer or A-buffer, scan-line method has depth info only for a single scan-line. In order to require one scan-line of depth values, we must group and process all polygons intersecting a given scan-line at the same time before process the next scan-line Build table of edges of all polygons in scene. Maintain active-edge- table as we visit each scan-line in scene. AET now contains edges for all polygons at that scanline. Must maintain flag for each surface to determine whether pixel on scan-line is inside that surface. scan-line

10
6/14/2015©Zachary Wartell Scan-Line Method Basic Example Scan Line 1: –(A,B) to (B,C) only inside S 1, so color from S 1 –(E,H) to (F,G) only inside S 2, so color from S 2 Scan Line 2: –(A,D) to (E,H) only inside S 1, so color from S 1 –(E,H) to (B,C) inside S 1 and S 2, so compute & test depth In this example we color from S 1 –(B,C) to (F,G) only inside S 2, so color from S 2 B A D C G F E H S1S1 S2S2 Scan Line 1 Scan Line 2 Scan Line 3

11
6/14/2015©Zachary Wartell Scan-Line Method Generalization This basic approach fails when surfaces cut-through each other or overlap. To generalize we must divide surfaces to eliminate overlaps

12
6/14/2015©Zachary Wartell Depth-Sorting Method Painter’s Algorithm Approach: –sorted surfaces by increasing depth may require surface splitting –scan-convert surfaces in sorted order (back to front) Use a sequence of sorting steps and tests of increasing computational complexity to handle all possible cases of polygon depth orderings

13
6/14/2015©Zachary Wartell Sort surfaces by each surface’s smallest z into list: (S 1,S 2,… S i … S N ) For all S i,i N If farthest surface S F has no z overlap render it. (easy case) If there is z overlap with S F, we can still avoid reordering if one of four conditions holds. So we test these conditions… Depth Sorting Details z S F =S 1 SiSi z min2 z max2 z min1 z max1 z S F =S 1 SiSi z min2 z max2 z min1 z max1 farther from PRP !

14
6/14/2015©Zachary Wartell Depth Sorting: Reorder Avoidance Tests We can avoid reorder if: 1) Bounding rectangles in xy don’t overlap 2) S f is completely behind overlapping surface relative to view position 3) Overlapping surface is completely in front of S f relative to view position 4) Boundary edges of projections of two surfaces on projection plane don’t overlap z SfSf S2S2 x min1 x max1 x min2 x max2 1) SfSf S2S2 2) 3) z z SfSf S2S2

15
6/14/2015©Zachary Wartell Depth Sorting: Reorder Avoidance Tests (cont.) 4) Boundary edges of projections of two surfaces on projection plane don’t overlap. (Knowing that bounding rectangles overlap from (1) doesn’t help. We must compute expensive polygon/polygon intersection).

16
6/14/2015©Zachary Wartell Depth Sort: Reordering If 1-4 fail, we swap S f and S. In general further swaps made be needed. Example: first swap S S'', but S'' occludes S' so swap S' and S'' to get final order S', S'',S z S'' S S'S' z SfSf S

17
6/14/2015©Zachary Wartell Depth Sort: Surface/Polygon Splitting It also is possible that there are cyclic occlusion relationships or surfaces penetrate. To deal with this we flag a surface when it is put at the end of the depth sort list and if we ever try to place a surface at the end more than once, we must split the polygon

18
6/14/2015©Zachary Wartell BSP-trees Binary Space Partition is a relatively easy way to sort the polygons relative to the eyepoint To Build a BSP Tree 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. If the plane intersects a polygon, divide the polygon at the plane. 3. Polygons are placed into a binary search tree with T as the root. 4. Call the procedure recursively on the left and right subtree. Larry F. Hodges, Drew Kessler

19
6/14/2015©Zachary Wartell BSP-Tree Example Larry F. Hodges, Drew Kessler

20
6/14/2015©Zachary Wartell Traversing BSP-Tree Traverse the BSP tree such that the branch descended first is the side that is away from the eyepoint. This can be determined by substituting the eye point into the plane equation for the polygon at the root. When there is no first branch to descend, or that branch has been completed then render the polygon at this node. After the current node's polygon has been rendered, descend the branch that is closer to the eyepoint. Larry F. Hodges, Drew Kessler

21
6/14/2015©Zachary Wartell Traversing BSP-Tree: Example EYE 1 +X-X C B A D E1 +Z F2 E2 F1 EYE 2 A C F1D E2 F2 B E1 Larry F. Hodges, Drew Kessler

22
6/14/2015©Zachary Wartell Splitting Triangles If all our polygons are triangles then we always divide a triangle into more triangles when it is intersected by the plane. It is possible for the number of triangles to increase exponentially but in practice it is found that the increase may be as small as two fold. A heuristic to help minimize the number of fractures is to enter the triangles into the tree in order from largest to smallest. Larry F. Hodges, Drew Kessler

23
6/14/2015©Zachary Wartell Area-Subdivision Method Recursively subdivide viewplane into quadrants until: –rectangle contains part of 1 projected surface –rectangle contains part of no surface –rectangle is size of pixel

24
6/14/2015©Zachary Wartell Area-Subdivision Method We need tests that can quickly determine tell if current area is part of one surface or if further subdivision is needed. Four cases for relation between surface and rectangular area: surrounding surface overlapping surface inside surface outside surface

25
6/14/2015©Zachary Wartell Area-Subdivision: Stopping Conditions Recursive subdivision can stop when either: 1) a rectangle has all surfaces outside 2) a rectangle has exactly one inside, overlapping, or surrounding surface 3) a rectangle has one surrounding surface and the surface occludes all other surfaces in the area For efficiency: –compare rectangle to projected surface bounding rectangle first. Only perform exact interaction test if necessary. If single bounding rect. intersects rectangle, test for exact intersection and color the framebuffer for the intersection of surface & rectangle.

26
6/14/2015©Zachary Wartell Testing Condition 3 sort surfaces on minimum depth from view plane for each surrounding surface for current rectangle compute maximum depth within rectangle subsection If maximum depth of a surrounding surface is closer to view plane than the minimum depths of all other surfaces within the area, condition 3 is achieved (i.e. surrounding surface occludes all others). z area z max

27
6/14/2015©Zachary Wartell Condition 3 Test need not be exhaustive There are cases that this computation will miss. Rather than performing further more expensive testing, we just subdivide the rectangle (i.e. don’t stop recursion). This choice is conservative: we may recurse when we don’t need (to avoid complex geometric computation), but as we continue recursive subdivision we will eventually compute exact answer because in limiting case rectangle is one pixel and in this case we simply calculate depth of each intersecting surface at that single point and set the framebuffer to the nearest surface’s color.

28
6/14/2015©Zachary Wartell Ray-Casting Method based geometric optics method that trace rays of light “backwards” light path tracing compare to depth buffer (surfaces to pixels versus pixel to surfaces) special case of ray-tracing COP pixel view plane

29
6/14/2015©Zachary Wartell Octrees Octree: –partitions 3-space by a regular, recursive subdivision of 3-space into axis-aligned boxes –3D objects are stored in the octree node that contains them. Recursively subdivide until each octree node is either empty, a homogeneous volume, or contains single object that’s “easy” to compute visibility (example can use back-face culling alone). 3 2 0 1 4 5 6 7 0 1 2 3 4 5 6 7 Any of these octants could then be recursively subdivide

30
6/14/2015©Zachary Wartell Octrees: Rendering Given a particular view, the octants can be ordered in view depth order. The order is the same for octants at all levels in the recursive subdivision. For general perspective viewing, traverse the octree in back-to-front order and render contents of each node (nearer object’s pixels overwrite farther object’s pixels). 3 2 0 1 4 5 6 7 view frustum For parallel projections with view planes parallel to octant faces, render front-to-back using a quadtree subdivision of the display window to record when a object has been drawn onto a region of the window.

31
6/14/2015©Zachary Wartell Comparison of visibility-detection methods effectiveness of method depends on surface distribution –wide distribution along view depth implies little depth overlap. This is ideal for depth-sorting and BSP-trees –few overlaps in surface view plane projections is ideal for scan- line or area-subdivision more generally –few surfaces implies few depth overlaps which is ideal for depth- sort or BSP-tree –scan-line also good for a few thousand polygon surfaces –for large number of surfaces octree or depth-buffer is better depth-buffer – tends to have constant computation cost as # of surfaces increases because more surfaces tends to imply individual surfaces are small (but beware of depth- complexity). Relative performance best for complex scenes. Octree – for parallel projection of volume data only need integer add/sub. operations

32
6/14/2015©Zachary Wartell Visibility Detection of Curve Surfaces ray-casting – compute ray surface intersections scan-line – compute intersection of scan-line’s extruded plane with surfaces octrees – chop up surfaces into pieces at octant boundaries depth-buffer – approximate surface with polygons surfaces represented as parametric, explicit or implicit equations –use efficient numerical approximation methods for computing surface intersections with parallel calculations or hardware implementation for common surfaces (quadrics, bezier-surfaces, etc.)

33
6/14/2015©Zachary Wartell Surface contour plots given some surface representation write it in view coordinate system (z is depth): y =f( x,z ) plot curves each at fixed z in front-to-back order and eliminate hidden sections. Increment z by Δz over surfaces visible z range. For each curve, iterate over x coordinate in screen coordinates, compute corresponding y and plot point ( x,y ). To eliminate hidden surfaces record ( y min,y max ) of plotted points for each x screen coordinate. Only plot point ( x,y ) if y is outside ( y min,y max ) at x.

34
6/14/2015©Zachary Wartell Wire-frame visibility methods wire-frame rendering of 3D object can be fast (fewer pixels to fill) and can emphasize various 3D features, but it becomes visually ambiguous as to what parts are in front/back of others Direct approach requires testing each line segment against each surface. Must work with projected coordinates of segment and surface boundaries. Hidden edges can be removed or drawn with dashes end points inside & behind end points inside & infront end points inside & infront & behind end points outside & behind at boundary end points outside & behind & infront at boundary

35
6/14/2015©Zachary Wartell Wire-Frame Depth Cueing Vary brightness of objects in scene as function of depth: Color of point is multiplied by f depth (d) Additionally we could simulate atmospheric effects (smog/haze) where farther pixels are paler in color

36
6/14/2015©Zachary Wartell OpenGL Visibility Back-face removal glFrontFace(ff); // ff {GL_CW,GL_CCW} glEnable(GL_CULL_FACE); glCullFace(mode); // mode {GL_BACK,GL_FRONT, GL_FRONT_AND_BACK} Depth-Buffer - tell GUI library to allocated depth-buffer for graphics windows - glClear (GL_DEPTH_BUFFER_BIT) -glEnabled (GL_DEPTH_TEST) -glClearDepth (maxDepth); // maxDepth [0.0,1.0] -glDepthRange (nearNormDepth,farNormDepth) //nearNormDepth [0.0,1.0], farNormDepth [0.0,1.0] -glDepthFunc (testCondition) //testCondition {GL_LESS,GL_GREATER,GL_EQUAL,GL_NOTEQUAL, // GL_LEQUAL,GLGEQUAL,GL_NEVER,GL_ALWAYS}

37
6/14/2015©Zachary Wartell OpenGL Visibility (cont.) Depth-Buffer –glDepthMask (writeStatus); // writeStatus {GL_TRUE,GL_FALSE} use for displaying single animated foreground object over static background object (disable write when drawing foreground object) use for approximate transparency (disable write when drawing transparent surface) Wire-frame Surface-Visibility Methods –glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) shows polygons as outlines –draw polygon twice. Once as outline using foreground color and once as filled polygon in background color. To prevent filled polygon pixels from interfering with outline pixels use glPolygonOffset Depth-Cueing –glEnable (GL_FOG) –glFogi (GL_FOG_MODE,GL_LINEAR) –glFogf (GL_FOG_START, minDepth) –glFogf (GL_FOG_END, maxDepth)

38
6/14/2015©Zachary Wartell Revisions Revision 1.2 –Integrated BSP and Depth Buffer slides from Hodges and Kessler Revision 1.3 - typos

Similar presentations

OK

1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.

1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on service oriented architecture soa Ppt on event driven programming in c# Ppt on the road not taken frost Ppt on content development Microsoft office ppt online templates Water cycle for kids ppt on batteries Ppt on how email works Ppt on natural and artificial satellites launched Ppt on information security and social networking Ppt on tribal group of india