Upload
brent
View
58
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Computer Graphics 2 Lecture 8: Visibility. Pr. Min Chen Dr. Benjamin Mora. University of Wales Swansea. 1. Benjamin Mora. Main techniques for visibility. Historical Techniques. Z-buffer techniques. Used Much. Basis for current hardware-accelerated Technologies. Ray-Tracing. - PowerPoint PPT Presentation
Citation preview
Computer Graphics 2Lecture 8:Visibility
Benjamin Mora 1University of Wales
Swansea
Pr. Min ChenDr. Benjamin Mora
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!
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.
Old Techniques
4Benjamin MoraUniversity of Wales
Swansea
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)
Priority List/BSP Trees (Fuch)
6Benjamin MoraUniversity of Wales
Swansea
1
12
2
3
55
3
44
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!
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
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.
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
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.
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
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.
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
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.
The Z-Buffer
16Benjamin MoraUniversity of Wales
Swansea
Z-Buffer test
17Benjamin MoraUniversity of Wales
Swansea
• Example:
Final image Final z-buffer
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
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
Extensions to these techniques
20Benjamin MoraUniversity of Wales
Swansea
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.
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
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
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)
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.
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.
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
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
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
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.
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.
Depth Peeling
32Benjamin MoraUniversity of Wales
Swansea
FromInteractive Order-Independent TransparencyCass EverittNVIDIA OpenGL Applications Engineering
Depth Peeling
33Benjamin MoraUniversity of Wales
Swansea
FromInteractive Order-Independent TransparencyCass EverittNVIDIA OpenGL Applications Engineering
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.