Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visibility II CS 446: Real-Time Rendering & Game Technology

Similar presentations


Presentation on theme: "Visibility II CS 446: Real-Time Rendering & Game Technology"— Presentation transcript:

1 Visibility II CS 446: Real-Time Rendering & Game Technology
David Luebke University of Virginia

2 Demo Time: Matt Spear NOTE: I’ve reorganized the next few demos:
Feb 21: Paul Tschirhart Feb 23: Erin Golub Feb 28: Sean Arietta Mar 2: Jiayuan Meng If this is a problem, let me know! Real-Time Rendering David Luebke

3 Assignment 3 Go over it Groups will be assigned before C.O.B. today…
Give your preferences on the forum! Feel free to augment these by saying what you like about each idea Real-Time Rendering David Luebke

4 Recap: Visibility Calculations
Motivation: avoid rendering redundant geometry Huge speedup, especially for indoor environments Basic idea: don’t render what can’t be seen Off-screen: view-frustum culling Occluded by other objects: occlusion culling Real-Time Rendering David Luebke

5 Recap: Potentially Visible Set
Our goal: quickly eliminate large portions of the scene which will not be visible in the final image Not the exact visibility solution, but a quick-and-dirty conservative estimate of which primitives may be visible Z-buffer& clip this for the exact solution This conservative estimate is called the potentially visible set or PVS Real-Time Rendering David Luebke

6 Recap: Cells & Portals Occlusion culling technique specialized for architectural models (buildings, cities, catacombs) These divide naturally into cells Rooms, alcoves, corridors… Transparent portals connect cells Doorways, entrances, windows… Notice: cells only see other cells through portals Real-Time Rendering David Luebke

7 Cells & Portals Idea: Cells form the basic unit of PVS
Create an adjacency graph of cells Starting with cell containing eyepoint, traverse graph, rendering visible cells A cell is only visible if it can be seen through a sequence of portals So cell visibility reduces to testing portal sequences for a line of sight… Real-Time Rendering David Luebke

8 Cells & Portals A D E F B C G H A E B C D F G H
Real-Time Rendering David Luebke

9 Cells & Portals A D E F B C G H A E B C D F G H
Real-Time Rendering David Luebke

10 Cells & Portals A D E F B C G H A E B C D F G H
Real-Time Rendering David Luebke

11 Cells & Portals A D E F B C G H A E B C D F G H
Real-Time Rendering David Luebke

12 Cells & Portals A D E F B C G H A E B C D F G H
Real-Time Rendering David Luebke

13 ? Cells & Portals A D E F B C G H A E B C D F G H ?
Real-Time Rendering David Luebke

14 Cells & Portals A D H F C B E G X Real-Time Rendering David Luebke

15 Cells & Portals View-independent solution: find all cells a particular cell could possibly see: C can only see A, D, E, and H A D H F C B E G A D E H Real-Time Rendering David Luebke

16 Cells & Portals View-independent solution: find all cells a particular cell could possibly see: H will never see F A D H F C B E G A D E B C G Real-Time Rendering David Luebke

17 Cells and Portals Questions: The key insight:
How can we detect whether a given cell is visible from a given viewpoint? How can we detect view-independent visibility between cells? The key insight: These problems reduce to eye-portal and portal-portal visibility Real-Time Rendering David Luebke

18 Recap: “Luebke/Georges” algorithm
Depth-first adjacency graph traversal Render cell containing viewer Treat portals as special polygons If portal is visible, render adjacent cell But clip to boundaries of portal! Recursively check portals in that cell against new clip boundaries (and render) Each visible portal sequence amounts to a series of nested portal boundaries Kept implicitly on recursion stack Real-Time Rendering David Luebke

19 Recap: “Luebke/Georges” algorithm
Recursively rendering cells while clipping to portal boundaries is not new Visible-surface algorithm (Jones 1971): general polygon-polygon clipping Elegant, expensive, complicated Conservative overestimate (pfPortals): use portal’s cull box Cull box = x-y screenspace bounding box Cheap to compute, very cheap to intersect Real-Time Rendering David Luebke

20 Recap: “Luebke/Georges” algorithm
How badly does the cull box approximation overestimate PVS? A: Not much for most architectural scenes Note: Can implement mirrors as portals with an extra transformation! Some clipping & Z-buffering issues Must limit recursion Real-Time Rendering David Luebke

21 Cells & Portals: Old Skool
Show the video… Real-Time Rendering David Luebke

22 Creating Cells and Portals
Given a model, how might you extract the cells and portals? Airey: k-D tree (axis-aligned boxes) Teller: BSP tree (general convex cells) Luebke: modeler/level designer (arbitrary cells) Problems and issues Running time Free cells Intra-wall cells Real-Time Rendering David Luebke

23 Cells and Portals: Discussion
Good solution for most architectural models Use the simplest algorithm that suffices for your needs: pfPortals-style algorithm: lightweight view-dependent solution, reasonably tight PVS, no preprocess necessary (except partition) Teller-style algorithm: even tighter PVS, somewhat more complex, can provide view-independent solution for prefetching Real-Time Rendering David Luebke

24 General Occlusion Culling
Clearly cells and portals don’t work for all models… Trees in a forest A crowded train station Other specialized visibility algorithms exist From colonoscopy to cityscapes… Need general occlusion culling algorithms: Aggregate occlusion Dynamic scenes Non-polygonal scenes Real-Time Rendering David Luebke

25 Image-Space Occlusion Culling
Many general occlusion culling algorithms use an image-space approach Idea: solve visibility in 2D, on the image plane Real-Time Rendering David Luebke

26 Hierarchical Z-Buffer
Replace Z-buffer with a Z-pyramid Lowest level: full-resolution Z-buffer Higher levels: each pixel represents the max depth of the four pixels “underneath” it Basic idea: hierarchical rasterization of the polygon, with early termination where polygon is occluded Real-Time Rendering David Luebke

27 Hierarchical Z-Buffer
Idea: test polygon against highest level first If polygon is further than distance recorded in pixel, stop—it’s occluded If polygon is closer, recursively check against next lower level If polygon is visible at lowest level, set new distance value and propagate up Real-Time Rendering David Luebke

28 Hierarchical Z-Buffer
Z-pyramid exploits image-space coherence: Polygon occluded in a pixel is probably occluded in nearby pixels HZB also exploits object-space coherence Polygons near an occluded polygon are probably occluded Real-Time Rendering David Luebke

29 Hierarchical Z-Buffer
Exploiting object-space coherence: Subdivide scene with an octree All geometry in an octree node is contained by a cube Before rendering the contents of a node, “test render” the faces of its cube (i.e., query the Z-pyramid) If cube faces are occluded, ignore the entire node Real-Time Rendering David Luebke

30 Hierarchical Z-Buffer
HZB can exploit temporal coherence Most polygons affecting the Z-buffer last frame will affect Z-buffer this frame HZB also operates at max efficiency when Z-pyramid already built So start each frame by rendering octree nodes visible last frame Real-Time Rendering David Luebke

31 Hierarchical Z-Buffer: Discussion
HZB needs hardware support to be really competitive Hardware vendors haven’t entirely bought in: Z-pyramid (and hierarchies in general) a pain in hardware Unpredictable Z-query times generate bubbles in rendering pipe But we’re getting there… ATI HyperZ Similar technology in NVIDIA Both “under the hood”, not exposed to programmer At the user level, hardware now supports occlusion queries Real-Time Rendering David Luebke

32 Modern Occlusion Culling
Support from hardware would be nice Want an “occlusion test”: would this polygon be visible if I rendered it? How could you use such a test? Test portal polygons before rendering adjacent cell Test object bounding boxes before rendering object Yay! GL_HP_OCCLUSION_TEST extension Problems: CPU/GPU synchronization == bad Might want to know “how visible” is the polygon Real-Time Rendering David Luebke

33 Modern Occlusion Culling
GL_ARB_OCCLUSION_QUERY to the rescue Non-blocking query “Is this occlusion query done yet?” Multiple queries in flight Returns number of fragments visible Note: can actually render object or not Still lots of issues for efficient culling Real-Time Rendering David Luebke

34 111 uses for Occlusion Queries
Occlusion culling (duh) Others? Approximate culling LOD size estimation Lens flare effects Transparency Collision detection (!) Convergence testing Real-Time Rendering David Luebke


Download ppt "Visibility II CS 446: Real-Time Rendering & Game Technology"

Similar presentations


Ads by Google