visibility culling iii: image-space occlusion david luebke computer science department university of...

30
Visibility Culling Visibility Culling III: III: Image-Space Image-Space Occlusion Occlusion David Luebke David Luebke Computer Science Computer Science Department Department University of Virginia University of Virginia <[email protected]> <[email protected]>

Upload: felicity-cooper

Post on 01-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

Visibility Culling III:Visibility Culling III:Image-Space OcclusionImage-Space Occlusion

David LuebkeDavid Luebke

Computer Science Computer Science DepartmentDepartment

University of VirginiaUniversity of Virginia

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

Page 2: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D2

Review: Review: General Occlusion General Occlusion

CullingCulling• When cells and portals don’t When cells and portals don’t

work…work…– Trees in a forestTrees in a forest– A crowded train stationA crowded train station

• Need general Need general occlusion cullingocclusion culling algorithms:algorithms:– Aggregate occlusion Aggregate occlusion – Dynamic scenesDynamic scenes– Non-polygonal scenesNon-polygonal scenes

Page 3: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D3

Review: Review: Hierarchical Z-BufferHierarchical Z-Buffer

• A A Z-pyramidZ-pyramid represents depth represents depth buffer in hierarchical fashionbuffer in hierarchical fashion– Depth at each pixel at a given level Depth at each pixel at a given level

represents the max of the depth of represents the max of the depth of the four corresponding pixels at the four corresponding pixels at next levelnext level

– Rasterize triangles into buffer Rasterize triangles into buffer hierarchically with early terminationhierarchically with early termination

Page 4: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D4

Review:Review:Hierarchical Z-BufferHierarchical Z-Buffer

• Organize scene into an Organize scene into an octreeoctree (a kind (a kind of spatial hierarchy)of spatial hierarchy)– Before rendering the polygons Before rendering the polygons

associated with a node in the octree, associated with a node in the octree, test if the node’s bbox is visibletest if the node’s bbox is visible

– Do an Do an occlusion queryocclusion query to “test render” to “test render” the faces of the bounding box against the faces of the bounding box against the depth-bufferthe depth-buffer

– If query fails, bbox would not be visible If query fails, bbox would not be visible and we can skip the node’s geometryand we can skip the node’s geometry

Page 5: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D5

Review: Review: Hierarchical Z-BufferHierarchical Z-Buffer

• HZB algorithm is most effective when HZB algorithm is most effective when Z-pyramid is “mostly complete”Z-pyramid is “mostly complete”– Start by rendering nodes visible last frame Start by rendering nodes visible last frame

directly into full-res Z-bufferdirectly into full-res Z-buffer– Build Z-pyramid from full-res Z-bufferBuild Z-pyramid from full-res Z-buffer– Traverse octree front-to-back, using Traverse octree front-to-back, using

Z-query to test nodes and render if Z-query to test nodes and render if neededneeded

• Note: also test nodes already rendered to see Note: also test nodes already rendered to see if they have become invisibleif they have become invisible

Page 6: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D6

Review: Review: Hierarchical Z-BufferHierarchical Z-Buffer

• HZB algorithm exploits:HZB algorithm exploits:– Image-space coherenceImage-space coherence: :

• Polygons occluded in one pixel are Polygons occluded in one pixel are probably occluded in nearby pixelsprobably occluded in nearby pixels

– Object-space coherenceObject-space coherence::• Polygons near an occluded polygon are Polygons near an occluded polygon are

probably also occludedprobably also occluded

– Temporal coherenceTemporal coherence::• Polygons visible recently are probably Polygons visible recently are probably

still visiblestill visible

Page 7: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D7

Hierarchical Hierarchical Occlusion MapsOcclusion Maps

• A more hardware-friendly general A more hardware-friendly general occlusion culling algorithmocclusion culling algorithm

• Two major differences from HZB:Two major differences from HZB:– Separates Separates occludersoccluders from from occludeesoccludees– Decouples occlusion test into an Decouples occlusion test into an

depth testdepth test and a and a overlap testoverlap test

Page 8: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D8

HierarchicalHierarchicalOcclusion MapsOcclusion Maps

• Occluders versus occludees:Occluders versus occludees:

Blue parts: Blue parts: occludersoccluders Red parts: Red parts: occludeesoccludees

Page 9: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D9

Hierarchical Hierarchical Occlusion MapsOcclusion Maps

• Depth versus overlap:Depth versus overlap:

ViewPoint

ZX

Y

Depth + Overlap = Depth + Overlap = OcclusionOcclusion Depth + Overlap = Depth + Overlap = OcclusionOcclusion

Page 10: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D10

Hierarchical Hierarchical Occlusion MapsOcclusion Maps

• Representation of projection for Representation of projection for overlap test: overlap test: occlusion mapocclusion map– Corresponds to a screen subdivisionCorresponds to a screen subdivision– Records average opacity per partitionRecords average opacity per partition

• Generate by rendering occludersGenerate by rendering occluders– Record pixel opacities (i.e., coverage)Record pixel opacities (i.e., coverage)

Page 11: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D11

Rendered Image Occlusion Map

Occlusion MapsOcclusion Maps

Page 12: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D12

Occlusion Map Occlusion Map PyramidPyramid

• Analyzing cumulative projection:Analyzing cumulative projection:– A A hierarchical occlusion maphierarchical occlusion map (HOM) (HOM)– Generate by recursive averaging Generate by recursive averaging

(once per frame)(once per frame)– Records average opacities for blocks Records average opacities for blocks

of multiple pixels, representing of multiple pixels, representing occlusion at multiple resolutionsocclusion at multiple resolutions

– Construction can be accelerated by Construction can be accelerated by texture hardwaretexture hardware

Page 13: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D13

Occlusion Map Occlusion Map PyramidPyramid

64 x 64 32 x 32 16 x 16

Page 14: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D14

Occlusion Map Occlusion Map PyramidPyramid

Page 15: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D15

Overlap TestsOverlap Tests

• Query: is projection of occludee inside Query: is projection of occludee inside cumulative projection of occluders?cumulative projection of occluders?– Cumulative projection: occlusion pyramidCumulative projection: occlusion pyramid– Occludee projection: expensive in generalOccludee projection: expensive in general

• Overestimate occludee with 3-D bounding boxOverestimate occludee with 3-D bounding box• Overestimate projection of 3-D bounding box Overestimate projection of 3-D bounding box

with 2-D bounding rectangle in screen-space with 2-D bounding rectangle in screen-space

Page 16: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D16

Overlap TestsOverlap Tests

• Hierarchical structure enables Hierarchical structure enables some optimizations:some optimizations:– Predictive rejectionPredictive rejection

• Terminate test when it must fail laterTerminate test when it must fail later

– Conservative rejectionConservative rejection• The transparency thresholdThe transparency threshold

– Aggressive Approximate CullingAggressive Approximate Culling• Ignore objects barely visible through Ignore objects barely visible through

holesholes• The opacity thresholdThe opacity threshold

Page 17: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D17

Aggressive Aggressive Approximate CullingApproximate Culling

0 1 2 3 4

Page 18: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D18

Hierarchical Hierarchical Occlusion MapsOcclusion Maps

• Not discussed here:Not discussed here:– Depth testDepth test

• Depth estimation bufferDepth estimation buffer• Modified Z-bufferModified Z-buffer

– Selecting occludersSelecting occluders

• For more details, see Hansong For more details, see Hansong Zhang’s dissertation at UNCZhang’s dissertation at UNC

Page 19: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D19

HOM: DiscussionHOM: Discussion

• Provides a robust, general, Provides a robust, general, hardware-friendly occlusion hardware-friendly occlusion culling algorithmculling algorithm– Supports dynamic scenesSupports dynamic scenes– Supports non-polygonal geometrySupports non-polygonal geometry– Few hardware assumptionsFew hardware assumptions

Page 20: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D20

HOM: DiscussionHOM: Discussion

• Not clear how relevant the actual Not clear how relevant the actual algorithm is on modern hardwarealgorithm is on modern hardware

• Most interesting/important points:Most interesting/important points:– Separation of occluders and occludeesSeparation of occluders and occludees– Factoring occlusion into overlap + depthFactoring occlusion into overlap + depth– Aggressive approximate cullingAggressive approximate culling

• To think about:To think about:– How could we simplify the occluders to How could we simplify the occluders to

accelerate occlusion testing?accelerate occlusion testing?

Page 21: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D21

Current Current Hardware SupportHardware Support

• Recent hardware supports Recent hardware supports Z-query operationZ-query operation– Allows systems to exploit:Allows systems to exploit:

• Object-space coherence (bounding boxes) Object-space coherence (bounding boxes) • Temporal coherence (last-rendered list)Temporal coherence (last-rendered list)

– Examples in OpenGL:Examples in OpenGL:• HP_OCCLUSION_QUERYHP_OCCLUSION_QUERY• NV_OCCLUSION_QUERYNV_OCCLUSION_QUERY• Go to NVIDIA occlusion presentation…Go to NVIDIA occlusion presentation…

– An aside: applies to cell-portal culling!An aside: applies to cell-portal culling!

Page 22: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D22

Visibility Culling: Visibility Culling: DiscussionDiscussion

• When is visibility culling When is visibility culling worthwhile?worthwhile?– When scene has high When scene has high depth depth

complexitycomplexity• Examples: architectural walkthroughs, Examples: architectural walkthroughs,

complex CAD assemblies, dense forest complex CAD assemblies, dense forest • Non-examples: terrain (usually), single Non-examples: terrain (usually), single

highly-tessellated object (e.g., bunny, highly-tessellated object (e.g., bunny, a radiositized room)a radiositized room)

Page 23: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D23

Visibility Culling:Visibility Culling:DiscussionDiscussion

• How does visibility culling compare to:How does visibility culling compare to:– Level-of-detail: Level-of-detail:

• Reduces geometry processingReduces geometry processing• Helps transform-bound appsHelps transform-bound apps

– Visibility culling: Visibility culling: • Reduces geometry Reduces geometry andand pixel processing pixel processing • Helps transform- and fill rate-bound appsHelps transform- and fill rate-bound apps

– Texture / Image representations: Texture / Image representations: • Reduces geometry Reduces geometry andand pixel processing pixel processing • Incurs texture/image processing costsIncurs texture/image processing costs

Page 24: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D24

Visibility Culling: Visibility Culling: DiscussionDiscussion

• How does visibility culling How does visibility culling interact with level of detail?interact with level of detail? – Fairly seamless integration; Fairly seamless integration;

generally a wingenerally a win– One issue: visibility of simplified One issue: visibility of simplified

model may differ from original model may differ from original model; requires some caremodel; requires some care

– LODs can speed up occluder LODs can speed up occluder selection and renderingselection and rendering

Page 25: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D25

Visibility Culling: Visibility Culling: DiscussionDiscussion

• How does visibility culling interact How does visibility culling interact with texture and image-based with texture and image-based representations?representations? – Texture/image reps generally replace Texture/image reps generally replace

far-field geometryfar-field geometry• Involves an implicit occlusion culling stepInvolves an implicit occlusion culling step• Reduces scene depth complexity, decreasing Reduces scene depth complexity, decreasing

the utility of visibility cullingthe utility of visibility culling• If near-field geometry still includes complex If near-field geometry still includes complex

heavily-occlusive assemblies, still a winheavily-occlusive assemblies, still a win

Page 26: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D26

Visibility Culling:Visibility Culling:DiscussionDiscussion

• How much culling effort is appropriate?How much culling effort is appropriate?– Cells and portals: relatively cheap, with large Cells and portals: relatively cheap, with large

potential speedupspotential speedups– Hierarchical occlusion maps: relatively costly, Hierarchical occlusion maps: relatively costly,

carefully weigh potential gainscarefully weigh potential gains– Multiple processors allow much more Multiple processors allow much more

aggressive culling calculationaggressive culling calculation• Pipelining culling calculations, Performer-style, Pipelining culling calculations, Performer-style,

allows allows cull time = render timecull time = render time

• Tradeoff: one frame increased latencyTradeoff: one frame increased latency

Page 27: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D27

SummarySummary

• The basic, very powerful idea:The basic, very powerful idea:– Rapidly compute a Rapidly compute a potentially visible potentially visible

setset– Let hardware handle the restLet hardware handle the rest

• For many scenes, visibility culling is For many scenes, visibility culling is a simple way to get huge speedupsa simple way to get huge speedups– View-frustum culling always a View-frustum culling always a mustmust – For scenes with high depth complexity, For scenes with high depth complexity,

occlusion culling can be a occlusion culling can be a bigbig win win

Page 28: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D28

SummarySummary

• Architectural models: visibility is Architectural models: visibility is practically a solved problempractically a solved problem– Cells and portals work wellCells and portals work well

• Cull-box portal culling: simple, fastCull-box portal culling: simple, fast• Line-stabbing: elegant, powerfulLine-stabbing: elegant, powerful

Page 29: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D29

SummarySummary

• Occlusion culling of general Occlusion culling of general models: still a largely open models: still a largely open problemproblem– Important issues: Important issues:

• Dynamic scenesDynamic scenes• Aggregate occlusion effects Aggregate occlusion effects

– Image-based approaches seem Image-based approaches seem most promising at this timemost promising at this time

Page 30: Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia

D30

SummarySummary

• General occlusion culling algorithms:General occlusion culling algorithms:– Hierarchical Z-buffer: Hierarchical Z-buffer:

• A simple, truly elegant algorithmA simple, truly elegant algorithm• But doesn’t seem amenable to hardwareBut doesn’t seem amenable to hardware

– Hierarchical occlusion maps: Hierarchical occlusion maps: • Separates occluders from occludees, overlap from Separates occluders from occludees, overlap from

depthdepth• Lends itself well to aggressive cullingLends itself well to aggressive culling• Fairly high overhead, only worthwhile with high Fairly high overhead, only worthwhile with high

depth complexitydepth complexity

– Recent hardware supports (asynchronous) Recent hardware supports (asynchronous) occlusion queryocclusion query