260 likes | 401 Views
Visibility Culling. David Luebke Computer Science Department University of Virginia <luebke@cs.virginia.edu>. Motivation. Like most other rendering acceleration techniques, the goal is to avoid rendering redundant geometry The basic idea: don’t render what can’t be seen
E N D
Visibility Culling David Luebke Computer Science Department University of Virginia <luebke@cs.virginia.edu>
Motivation • Like most other rendering acceleration techniques, the goal is to avoid rendering redundant geometry • The basic idea: don’t render what can’t be seen • Off-screen: view-frustum culling • Occluded by other objects: occlusion culling
Motivation • The obvious question: why bother? • Off-screen geometry: solved by clipping • Occluded geometry: solved by Z-buffer • The (obvious) answer: efficiency • Clipping and Z-buffering take time linear to the number of primitives
The Goal • 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 might be visible • Z-buffer& clip this for the exact solution • This conservative estimate is called the potentially visible set or PVS
Visibility Culling • The remainder of this talk will cover: • View-frustum culling (briefly) • Occlusion culling in architectural environments • General occlusion culling
View-Frustum Culling • An old idea (Clark 76): • Organize primitives into clumps • Before rendering the primitives in a clump, test a bounding volume against the view frustum • If the clump is entirely outside the view frustum, don’t render any of the primitives • If the clump intersects the view frustum, add to PVS and render normally
Efficient View-Frustum Culling • How big should the clumps be? • Choose minimum size so:cost testing bounding volume << cost clipping primitives • Organize clumps into a hierarchy of bounding volumes for more efficient testing • If a clump is entirely outside or entirely inside view frustum, no need to test its children
Efficient View-Frustum Culling • What shape should bounding volumes be? • Spheres and axis-aligned bounding boxes: simple to calculate, cheap to test • Oriented bounding boxesconverge asymptotically faster in theory • Lots of other volumes have been proposed • Capsules, ellipsoids, k-DOPs • …but most use spheres or AABBs.
Cells & Portals • Goal: walk through architectural models (buildings, cities, catacombs) • These divide naturally into cells • Rooms, alcoves, corridors… • Transparent portalsconnect cells • Doorways, entrances, windows… • Notice: cells only see other cells through portals
Cells & Portals • An example:
Cells & Portals • Idea: • Cells form the basic unit of PVS • Create an adjacency graphof 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…
Cells & Portals A D E F B C G H A E B C D F G H
Cells & Portals A D E F B C G H A E B C D F G H
Cells & Portals A D E F B C G H A E B C D F G H
Cells & Portals A D E F B C G H A E B C D F G H
Cells & Portals A D E F B C G H A E B C D F G H
Cells & Portals A D E ? F B C G H A E B C D F G ? H
Cells & Portals A D E X F B C G H A E B C D F G X H
A D E F B C G H 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 E H
A D E F B C G H Cells & Portals • View-independent solution: find all cells a particular cell could possibly see: H will never see F A D E B C G
Cells and Portals • Questions: • 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
Cells and Portals • Airey (1990): view-independent only • Portal-portal visibility determined by ray-casting • Non-conservative portal-portal test resulted in occasional errors in PVS • Slow preprocess • Order-of-magnitude speedups
Cells and Portals • Teller (1993): view-independent + view-dependent • Portal-portal visibility calculated by line stabbing using linear program • Cell-cell visibility stored in stab trees • View-dependent eye-portal visibility stage further refines PVS at run time • Slow preprocess • Elegant, exact scheme
Cells and Portals • Luebke (1995): view-dependent only • Eye-portal visibility determined by intersecting portal cull boxes • No preprocess (integrate w/ modeling) • Quick, simple hack • Public-domain library: pfPortals
pfPortals 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