Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.

Similar presentations


Presentation on theme: "Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora."— Presentation transcript:

1 Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora

2 Main techniques for visibility 2 Benjamin Mora University of Wales Swansea Historical Techniques. Z-buffer techniques. –Used Much. –Basis for current hardware-accelerated Technologies. Ray-Tracing. –See Next Lecture!

3 Content 3 Benjamin Mora University of Wales Swansea Painter & Priority Lists Algorithms. Cells and Portals. Area subdivision algorithms. –Warnock and Weiler Atherton algorithms. Scan line algorithms. The z-buffer algorithm. Extensions. –Culling. –Hidden Surface Removal Hierarchical Occlusion maps. Hierarchical z. –Depth peeling. –Soft Shadows. –Shadow mapping.

4 Old Techniques 4 Benjamin Mora University of Wales Swansea

5 Painter’s Algorithm 5 Benjamin Mora University of Wales Swansea Painter’s Algorithm: –Only if graphics primitives can be separated by planes. Primitive can be projected from the farthest one to the closest (Back-to-Front) without any need to find the closest intersection. All the primitives being on the same side of the viewpoint (A) will be intersected first, so a Front-to-back analysis is more efficient. (A) (B)

6 Priority List/BSP Trees (Fuch) 6 Benjamin Mora University of Wales Swansea 1 1 2 2 3 5 5 3 4 4

7 Priority List/BSP Trees (Fuch) 7 Benjamin Mora University of Wales Swansea Proposed by Henry Fuch (1980). By preprocessing the scene and creating a binary space subdivision, primitives can then be projected in a visibility order. Handles Transparency correctly. In practice, constructing a Binary Space Partitioning tree is difficult!

8 Cells and Portals 8 Benjamin Mora University of Wales Swansea In architectural scenes, rooms are usually not visible from other rooms. Used in 3D games (with Z-buffering). A visibility graph is usually associated to the scene. A BF CE D A E B C D F

9 Cells and Portals 9 Benjamin Mora University of Wales Swansea However: –Do not work with scenes like forest, clouds,… –Needs to pre-compute the graph. Dynamic scenes are an issue. –Sorting out visibility inside the cells is still required. Sometime a method that can compute visibility in real-time (on-the-fly) is needed. –Z-Buffer/Hierarchical Z-buffer. –Hierarchical Occlusions Maps. –Occlusion queries.

10 Area Subdivision Algorithms 10 Benjamin Mora University of Wales Swansea Warnock Algorithm (1969). –Not really used anymore. –Hierarchical method. –Quadtree structure. –Assumes no overlapping –Visibility is computed on a per-block basis. http://www.evl.uic.edu/aej/488/diagrams/areasub.gif

11 Area Subdivision Algorithms 11 Benjamin Mora University of Wales Swansea Weiler-Atherton algorithm –Kevin Weiler, Peter Atherton, “Hidden surface removal using polygon area sorting”, Siggraph 1977. –Works on 3D primitives instead of using screen space subdivisions. –Maintains a list of clipped (visible) polygons. Every time a new polygon is processed, clipping with all the (visible) polygons is performed and a new list of polygons is generated. Once all the polygons processed, the clipped parts can be used for the final image.

12 Area Subdivision Algorithms 12 Benjamin Mora University of Wales Swansea Weiler Atherton algorithm. –Provides a general clipping algorithm for concave polygons. –Other algorithm for clipping: Sutherland- Hodgman algorithm. Subject Polygon Clip Polygon

13 Scanline (Watkins 70) 13 Benjamin Mora University of Wales Swansea Watkins, G.S. A real-time visible surface algorithm. UTEC-CSc-70-101, Computer Science Dept., Univ. of Utah, June 1970. Principles similar to Weiler Atherton algorithm, but uses 1D clipping (line) only. –Maintains a list of clipped lines for every row. Scan-line term used for rasterization algorithms.

14 Scanline (Watkins 70) 14 Benjamin Mora University of Wales Swansea Image p1p1 p2p2 Triangle #1 p1p1 p2p2 p1p1 p3p3 p3p3 p4p4 p4p4 p2p2 p3p3 p4p4 Triangle #2 Scan Line y Primitive list Row y

15 Possible Issues with these algorithms 15 Benjamin Mora University of Wales Swansea Could be too complex (e.g., 2D clipping). –Lead to several cases and bugs in implementations. Not fast enough. –E.g. clipping. Hardly parallelizable. –Not suitable to hardware acceleration.

16 The Z-Buffer 16 Benjamin Mora University of Wales Swansea

17 Z-Buffer test 17 Benjamin Mora University of Wales Swansea Example: Final image Final z-buffer

18 Z-Buffer test 18 Benjamin Mora University of Wales Swansea Used by current hardware technology. Primitives can be sent to the graphics hardware in any order, thanks to the z-buffer test that will keep the closest fragments. A z value is stored for every pixel (z-buffer). Algorithm for a given pixel: If the rasterized z-value is less than the current z-value Then replace the previous color and z-value by the new ones

19 Z-Buffer test 19 Benjamin Mora University of Wales Swansea A scan line algorithm can be used to find all the pixels on the projection of a single triangle. Lines are filled with colors if the pixels pass the z- test. Row y Row y+1 Row y+2

20 Extensions to these techniques 20 Benjamin Mora University of Wales Swansea

21 Culling 21 Benjamin Mora University of Wales Swansea Why ? –To avoid processing geometry that does not need to be processed. –Useful when having millions (or billions) of triangles. –Can be done at the triangle or pixel level. View Frustum Culling. Back Face Culling. Occlusion Culling.

22 Culling 22 Benjamin Mora University of Wales Swansea View Frustum Culling. –Primitives outside of the view frustum discarded. –Implemented on graphics cards. Viewpoint Viewing pyramid Visible Triangle Culled triangles

23 Culling 23 Benjamin Mora University of Wales Swansea Can be accelerated (software) by grouping triangle and computing the frustum intersection only for the bounding box. Don’t need to process these triangles. Frustum Bounding Box

24 Culling 24 Benjamin Mora University of Wales Swansea Back Face Culling. –If the viewpoint is fronting the backface, then the triangle is not processed. –Hardware accelerated –Can be enabled/disabled. –Orientation given by the order of projected vertices. Projected Triangle (Visible) #1 #2#3 #1 #3#2 Wrong vertex order (Triangle is culled)

25 Occlusion Culling 25 Benjamin Mora University of Wales Swansea A set of algorithms to avoid processing hidden geometry/surfaces –Hierarchical Occlusion Maps. –Hierarchical z-buffer. –Occlusion queries.

26 Hierarchical Occlusion Maps 26 Benjamin Mora University of Wales Swansea Hansong Zhang, Dinesh Manocha, Tom Hudson Kenneth E. Hoff III. Visibility Culling using Hierarchical Occlusion Maps. Siggraph 1997. Proposed by Zhang et al. Similar to Hierarchical z. Only occlusion is stored here.

27 Hierarchical Occlusion Maps 27 Benjamin Mora University of Wales Swansea Triangles are initially grouped into separate regions of space such as bounding boxes, grids or trees. This data structure is traversed in a front to back order. –The visibility of the region is given by the HOM. –If region is visible, then its content (i.e., triangles) must be projected. –During projection, the content of the different maps is updated every time a pixel becomes opaque. Not used by current hardware. –Hierarchical-z instead

28 Hierarchical Z-buffer 28 Benjamin Mora University of Wales Swansea Proposed by Greene et al. A hierarchical z-max pyramid is constructed above the z-buffer. Every time a z value is updated, the hierarchy is updated. Ned Greene, Michael Kass and Gavin Miller. Hierarchical Z-Buffer Visibility. Siggraph 1993. 6 5 4 2 3 5 7 6 2 5 4 2 9 1 3 2 6 7 9 4 9 8 8 8

29 Hierarchical Z-buffer 29 Benjamin Mora University of Wales Swansea Current ATI and NVidia graphics card implement a limited z-hierarchy. Efficient when objects are projected in a front-to-back way. ATI Hyper-Z III: http://graphics.tomshardware.com/graphic/20020718/radeon9700-08.html

30 Occlusion Queries 30 Benjamin Mora University of Wales Swansea New Graphics Hardware allows counting the number of fragments that pass the z-test. 3 steps: –Lock the z-buffer and frame buffer (impossible to modify the content of these buffers). –Render a bounding box. If no pixel has passed the z-test, then the region inside the BB is not visible. –Unlock the Z-buffer and Frame-Buffer.

31 Occlusion Queries 31 Benjamin Mora University of Wales Swansea Can take advantage of fast z tests. Efficient only if the BB contains many primitives. Must wait for the answer. –The program should do something before testing the answer. –Occlusions should be chained in order to avoid an empty graphics pipeline.

32 Depth Peeling 32 Benjamin Mora University of Wales Swansea From Interactive Order-Independent Transparency Cass Everitt NVIDIA OpenGL Applications Engineering

33 Depth Peeling 33 Benjamin Mora University of Wales Swansea From Interactive Order-Independent Transparency Cass Everitt NVIDIA OpenGL Applications Engineering

34 Depth Peeling 34 Benjamin Mora University of Wales Swansea Z-buffer based visibility only allows finding the nearest elements of the scene. –Transparency cannot correctly be handled. Solution: use a multipass algorithm to find the second nearest surface, third nearest surface, and etc… for every pixel –At the end, combine the different images in a front-to-back-order.


Download ppt "Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora."

Similar presentations


Ads by Google