Download - Visibility Culling

Transcript
Page 1: Visibility Culling

Visibility CullingVisibility CullingDavid LuebkeDavid Luebke

Computer Science Computer Science DepartmentDepartment

University of VirginiaUniversity of Virginia

<[email protected]><[email protected]>

Page 2: Visibility Culling

D2

MotivationMotivation• Like most other rendering Like most other rendering

acceleration techniques, the goal is acceleration techniques, the goal is to avoid rendering redundant to avoid rendering redundant geometrygeometry

• The basic idea: don’t render what The basic idea: don’t render what can’t be seencan’t be seen– Off-screen: Off-screen: view-frustum cullingview-frustum culling– Occluded by other objects: Occluded by other objects: occlusion occlusion

cullingculling

Page 3: Visibility Culling

D3

MotivationMotivation• The obvious question: The obvious question: why bother?why bother?

– Off-screen geometry: Off-screen geometry: solved by clippingsolved by clipping

– Occluded geometry: Occluded geometry: solved by Z-buffersolved by Z-buffer

• The (obvious) answer: The (obvious) answer: efficiencyefficiency– Clipping and Z-buffering take time Clipping and Z-buffering take time

linear to the number of primitiveslinear to the number of primitives

Page 4: Visibility Culling

D4

The GoalThe Goal• Our goal: Our goal: quicklyquickly eliminate large eliminate large

portions of the scene which will portions of the scene which will not be visible in the final imagenot be visible in the final image– Not the exact visibility solution, but Not the exact visibility solution, but

a quick-and-dirty a quick-and-dirty conservativeconservative estimate of which primitives might estimate of which primitives might be visiblebe visible

• Z-buffer& clip this for the exact solutionZ-buffer& clip this for the exact solution– This conservative estimate is called This conservative estimate is called

the the potentially visible setpotentially visible set or PVS

Page 5: Visibility Culling

D5

Visibility CullingVisibility Culling• The remainder of this talk will The remainder of this talk will

cover:cover:– View-frustum culling (briefly)View-frustum culling (briefly)– Occlusion culling in architectural Occlusion culling in architectural

environments environments – General occlusion cullingGeneral occlusion culling

Page 6: Visibility Culling

D6

View-Frustum View-Frustum CullingCulling

• An old idea (Clark 76):An old idea (Clark 76):– Organize primitives into clumpsOrganize primitives into clumps– Before rendering the primitives in a Before rendering the primitives in a

clump, test a clump, test a bounding volumebounding volume against the view frustumagainst the view frustum

• If the clump is entirely outside the view If the clump is entirely outside the view frustum, don’t render any of the frustum, don’t render any of the primitivesprimitives

• If the clump intersects the view frustum, If the clump intersects the view frustum, add to PVS and render normallyadd to PVS and render normally

Page 7: Visibility Culling

D7

Efficient Efficient View-Frustum View-Frustum

CullingCulling• How big should the clumps be?How big should the clumps be?

– Choose minimum size so:Choose minimum size so:

cost cost testing bounding volumetesting bounding volume << << cost cost clipping primitivesclipping primitives

– Organize clumps into a hierarchy of Organize clumps into a hierarchy of bounding volumes for more efficient bounding volumes for more efficient testingtesting

• If a clump is entirely outside or entirely inside If a clump is entirely outside or entirely inside view frustum, no need to test its childrenview frustum, no need to test its children

Page 8: Visibility Culling

D8

Efficient Efficient View-Frustum View-Frustum

CullingCulling• What shape should bounding What shape should bounding

volumes be?volumes be?– Spheres and axis-aligned bounding Spheres and axis-aligned bounding

boxes: simple to calculate, cheap to testboxes: simple to calculate, cheap to test– Oriented bounding boxesOriented bounding boxes converge converge

asymptotically faster in theoryasymptotically faster in theory– Lots of other volumes have been Lots of other volumes have been

proposedproposed• Capsules, ellipsoids, k-DOPsCapsules, ellipsoids, k-DOPs

– ……but most use spheres or AABBs.but most use spheres or AABBs.

Page 9: Visibility Culling

D9

Cells & PortalsCells & Portals• Goal: walk through architectural Goal: walk through architectural

models (buildings, cities, catacombs)models (buildings, cities, catacombs)• These divide naturally into These divide naturally into cellscells

– Rooms, alcoves, corridors… Rooms, alcoves, corridors… • Transparent Transparent portalsportals connect cellsconnect cells

– Doorways, entrances, windows… Doorways, entrances, windows…

• Notice: cells only see other cells Notice: cells only see other cells through portalsthrough portals

Page 10: Visibility Culling

D10

Cells & PortalsCells & Portals• An example:An example:

Page 11: Visibility Culling

D11

Cells & PortalsCells & Portals• Idea: Idea:

– Cells form the basic unit of PVSCells form the basic unit of PVS– Create an Create an adjacency graphadjacency graph of cells– Starting with cell containing Starting with cell containing

eyepoint, traverse graph, rendering eyepoint, traverse graph, rendering visible cells visible cells

– A cell is only visible if it can be seen A cell is only visible if it can be seen through a sequence of portalsthrough a sequence of portals

• So cell visibility reduces to testing So cell visibility reduces to testing portal sequences for a portal sequences for a line of sight…line of sight…

Page 12: Visibility Culling

D12

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

Page 13: Visibility Culling

D13

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

Page 14: Visibility Culling

D14

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

Page 15: Visibility Culling

D15

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

Page 16: Visibility Culling

D16

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

Page 17: Visibility Culling

D17

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

?

??

Page 18: Visibility Culling

D18

Cells & PortalsCells & Portals

AD

H

FCB

E

G

H

B C D F G

EA

X

XX

Page 19: Visibility Culling

D19

Cells & PortalsCells & Portals• View-independentView-independent solution: find all solution: find all

cells a particular cell could cells a particular cell could possiblypossibly see:see:

C can C can onlyonly see A, D, E, and H see A, D, E, and H

AD

H

FCB

E

G

AD

H

E

Page 20: Visibility Culling

D20

Cells & PortalsCells & Portals• View-independentView-independent solution: find all solution: find all

cells a particular cell could cells a particular cell could possiblypossibly see:see:

H will H will nevernever see F see F

AD

H

FCB

E

G

AD

CB

E

G

Page 21: Visibility Culling

D21

Cells and PortalsCells and Portals• Questions:Questions:

– How can we detect whether a given How can we detect whether a given cell is visible from a given viewpoint?cell is visible from a given viewpoint?

– How can we detect view-independent How can we detect view-independent visibility between cells?visibility between cells?

• The The key insightkey insight: : – These problems reduce to eye-portal These problems reduce to eye-portal

and portal-portal visibilityand portal-portal visibility

Page 22: Visibility Culling

D22

Cells and PortalsCells and Portals• Airey (1990): view-independent Airey (1990): view-independent

onlyonly– Portal-portal visibility determined Portal-portal visibility determined

by ray-casting by ray-casting • Non-conservative portal-portal test Non-conservative portal-portal test

resulted in occasional errors in PVSresulted in occasional errors in PVS– Slow preprocessSlow preprocess– Order-of-magnitude speedupsOrder-of-magnitude speedups

Page 23: Visibility Culling

D23

Cells and PortalsCells and Portals• Teller (1993): view-independent Teller (1993): view-independent

+ view-dependent+ view-dependent– Portal-portal visibility calculated by Portal-portal visibility calculated by

line stabbing line stabbing using linear programusing linear program• Cell-cell visibility stored in Cell-cell visibility stored in stab treesstab trees • View-dependent eye-portal visibility View-dependent eye-portal visibility

stage further refines PVS at run timestage further refines PVS at run time– Slow preprocessSlow preprocess– Elegant, exact schemeElegant, exact scheme

Page 24: Visibility Culling

D24

Cells and PortalsCells and Portals• Luebke (1995): view-dependent Luebke (1995): view-dependent

onlyonly– Eye-portal visibility determined by Eye-portal visibility determined by

intersecting portal intersecting portal cull boxescull boxes– No preprocess (integrate w/ No preprocess (integrate w/

modeling)modeling)– Quick, simple hackQuick, simple hack– Public-domain library: Public-domain library: pfPortalspfPortals

Page 25: Visibility Culling

D25

pfPortals AlgorithmpfPortals Algorithm• Depth-first adjacency graph traversalDepth-first adjacency graph traversal

– Render cell containing viewerRender cell containing viewer– Treat portals as special polygonsTreat portals as special polygons

• If portal is visible, render adjacent cellIf portal is visible, render adjacent cell• But clip to boundaries of portal!But clip to boundaries of portal!• Recursively check portals in that cell against Recursively check portals in that cell against

new clip boundaries (and render) new clip boundaries (and render) – Each visible Each visible portal sequenceportal sequence amounts to amounts to

a series of nested portal boundaries a series of nested portal boundaries • Kept implicitly on recursion stackKept implicitly on recursion stack


Top Related