computer graphics 2 lecture 8: visibility benjamin mora 1 university of wales swansea pr. min chen...
TRANSCRIPT
![Page 1: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/1.jpg)
Computer Graphics 2Lecture 8:Visibility
Benjamin Mora 1University of Wales
Swansea
Pr. Min ChenDr. Benjamin Mora
![Page 2: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/2.jpg)
Main techniques for visibility
2Benjamin MoraUniversity of Wales
Swansea
• Historical Techniques.
• Z-buffer techniques.– Used Much.– Basis for current hardware-accelerated
Technologies.
• Ray-Tracing.– See Next Lecture!
![Page 3: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/3.jpg)
Content
3Benjamin MoraUniversity 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.
![Page 4: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/4.jpg)
Old Techniques
4Benjamin MoraUniversity of Wales
Swansea
![Page 5: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/5.jpg)
Painter’s Algorithm
5Benjamin MoraUniversity 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)
![Page 6: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/6.jpg)
Priority List/BSP Trees (Fuch)
6Benjamin MoraUniversity of Wales
Swansea
1
12
2
3
55
3
44
![Page 7: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/7.jpg)
Priority List/BSP Trees (Fuch)
7Benjamin MoraUniversity 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!
![Page 8: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/8.jpg)
Cells and Portals
8Benjamin MoraUniversity 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
B F
C E
D
A
E
B
CD
F
![Page 9: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/9.jpg)
Cells and Portals
9Benjamin MoraUniversity 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.
![Page 10: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/10.jpg)
Area Subdivision Algorithms
10Benjamin MoraUniversity 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
![Page 11: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/11.jpg)
Area Subdivision Algorithms
11Benjamin MoraUniversity 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.
![Page 12: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/12.jpg)
Area Subdivision Algorithms
12Benjamin MoraUniversity 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
![Page 13: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/13.jpg)
Scanline (Watkins 70)
13Benjamin MoraUniversity 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.
![Page 14: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/14.jpg)
Scanline (Watkins 70)
14Benjamin MoraUniversity of Wales
Swansea
Image
p1 p2
Triangle #1
p1 p2
p1 p3
p3 p4
p4 p2p3 p4
Triangle #2
Scan Line y
Primitive list
Row y
![Page 15: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/15.jpg)
Possible Issues with these algorithms
15Benjamin MoraUniversity 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.
![Page 16: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/16.jpg)
The Z-Buffer
16Benjamin MoraUniversity of Wales
Swansea
![Page 17: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/17.jpg)
Z-Buffer test
17Benjamin MoraUniversity of Wales
Swansea
• Example:
Final image Final z-buffer
![Page 18: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/18.jpg)
Z-Buffer test
18Benjamin MoraUniversity 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
![Page 19: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/19.jpg)
Z-Buffer test
19Benjamin MoraUniversity 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 yRow y+1
Row y+2
![Page 20: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/20.jpg)
Extensions to these techniques
20Benjamin MoraUniversity of Wales
Swansea
![Page 21: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/21.jpg)
Culling
21Benjamin MoraUniversity 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.
![Page 22: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/22.jpg)
Culling
22Benjamin MoraUniversity of Wales
Swansea
• View Frustum Culling.– Primitives outside of the view frustum discarded.– Implemented on graphics cards.
Viewpoint
Viewing pyramid
Visible Triangle
Culled triangles
![Page 23: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/23.jpg)
Culling
23Benjamin MoraUniversity 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
![Page 24: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/24.jpg)
Culling
24Benjamin MoraUniversity 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#2Wrong vertex order
(Triangle is culled)
![Page 25: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/25.jpg)
Occlusion Culling
25Benjamin MoraUniversity of Wales
Swansea
• A set of algorithms to avoid processing hidden geometry/surfaces
– Hierarchical Occlusion Maps.
– Hierarchical z-buffer.
– Occlusion queries.
![Page 26: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/26.jpg)
Hierarchical Occlusion Maps
26Benjamin MoraUniversity 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.
![Page 27: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/27.jpg)
Hierarchical Occlusion Maps
27Benjamin MoraUniversity 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
![Page 28: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/28.jpg)
Hierarchical Z-buffer
28Benjamin MoraUniversity 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.
6542
3576
2542
9132
67
94
9
88
8
![Page 29: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/29.jpg)
Hierarchical Z-buffer
29Benjamin MoraUniversity 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
![Page 30: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/30.jpg)
Occlusion Queries
30Benjamin MoraUniversity 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.
![Page 31: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/31.jpg)
Occlusion Queries
31Benjamin MoraUniversity 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.
![Page 32: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/32.jpg)
Depth Peeling
32Benjamin MoraUniversity of Wales
Swansea
FromInteractive Order-Independent TransparencyCass EverittNVIDIA OpenGL Applications Engineering
![Page 33: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/33.jpg)
Depth Peeling
33Benjamin MoraUniversity of Wales
Swansea
FromInteractive Order-Independent TransparencyCass EverittNVIDIA OpenGL Applications Engineering
![Page 34: Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora](https://reader031.vdocuments.us/reader031/viewer/2022013004/56649eb45503460f94bbcb5e/html5/thumbnails/34.jpg)
Depth Peeling
34Benjamin MoraUniversity 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.