visibility algorithms for computer graphics
DESCRIPTION
Visibility Algorithms for Computer Graphics. CS 551/645 Introduction to Computer Graphics Guest lecture by David Luebke. But First…. CS 551/651: Advanced Computer Graphics I’m teaching next semester Follows and builds on 551/645. Topics: Photorealism: Ray tracing, path tracing, radiosity - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/1.jpg)
David Luebke 11-2-98
Visibility Algorithms for Visibility Algorithms for Computer GraphicsComputer Graphics
CS 551/645 CS 551/645 Introduction to Computer GraphicsIntroduction to Computer Graphics
Guest lecture by David LuebkeGuest lecture by David Luebke
![Page 2: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/2.jpg)
David Luebke 11-2-98
But First…But First…
CS 551/651: Advanced Computer GraphicsCS 551/651: Advanced Computer Graphics– I’m teaching next semesterI’m teaching next semester– Follows and builds on 551/645. Topics:Follows and builds on 551/645. Topics:
Photorealism: Ray tracing, path tracing, radiosityPhotorealism: Ray tracing, path tracing, radiosity Speed: Occlusion culling, level-of-detail, texture tricksSpeed: Occlusion culling, level-of-detail, texture tricks Hardware: rendering pipeline, graphics architecturesHardware: rendering pipeline, graphics architectures Non-photorealism: pen-and-ink, painterly renderingNon-photorealism: pen-and-ink, painterly rendering Image-based rendering: image warping, sprites, Image-based rendering: image warping, sprites,
layered-depth imageslayered-depth images
– Will also be taught in grad/undergrad formatsWill also be taught in grad/undergrad formats
![Page 3: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/3.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray tracingRay tracing
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– Occlusion cullingOcclusion culling
![Page 4: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/4.jpg)
David Luebke 11-2-98
Recap: The Visible Recap: The Visible Surface ProblemSurface Problem
Problem: Many polygons may map Problem: Many polygons may map to same pixel on screen.to same pixel on screen.
Goal: Correctly color pixels, using Goal: Correctly color pixels, using only only unoccludedunoccluded polygons polygons
Formally, Formally, aa occludes occludes bb if: if:– aa and and bb are on the same projector are on the same projector– aa is closer to the center of projection is closer to the center of projection
![Page 5: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/5.jpg)
David Luebke 11-2-98
Recap: Recap: Painter’s AlgorithmPainter’s Algorithm
Idea: do what painters do Idea: do what painters do – Sort objects by depthSort objects by depth– Draw objects from distant to nearDraw objects from distant to near– Just overwrite already-drawn objects Just overwrite already-drawn objects
as you goas you go
![Page 6: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/6.jpg)
David Luebke 11-2-98
Recap:Recap:Painter’s Algorithm Painter’s Algorithm
Pros:Pros:– Simple, fast rasterizationSimple, fast rasterization
Cons: Cons: – Sorting is O(Sorting is O(nn lg lg nn), and ), and nn can get big can get big– Some objects can’t be sorted by depth:Some objects can’t be sorted by depth:
![Page 7: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/7.jpg)
David Luebke 11-2-98
Recap: Z-BufferRecap: Z-Buffer
Idea: resolve visibility Idea: resolve visibility at each pixelat each pixel– Store depth of nearest polygon at pixelStore depth of nearest polygon at pixel– Reset pixel color & depth only if nearer Reset pixel color & depth only if nearer
polygon is foundpolygon is found– Embed this test in rasterization loopEmbed this test in rasterization loop
Pros: simple, linear-time algorithmPros: simple, linear-time algorithm Cons: Read-Modify-Write in inner loop Cons: Read-Modify-Write in inner loop
demands large, fast, dedicated memory demands large, fast, dedicated memory bank (the bank (the Z-bufferZ-buffer))
![Page 8: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/8.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray tracingRay tracing
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– Occlusion cullingOcclusion culling
![Page 9: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/9.jpg)
David Luebke 11-2-98
Binary Space PartitionBinary Space Partition(BSP) Trees(BSP) Trees
Fuchs et al, 1980Fuchs et al, 1980 Assumptions:Assumptions:
– Static sceneStatic scene– Moving cameraMoving camera
Commonly used in 3-D video games Commonly used in 3-D video games (e.g., Quake), but going out of style(e.g., Quake), but going out of style
Still a very powerful, general idea, Still a very powerful, general idea, used in many graphics algorithmsused in many graphics algorithms
![Page 10: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/10.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
– PreprocessPreprocess: overlay a binary (BSP) : overlay a binary (BSP) tree on objects in the scenetree on objects in the scene
– RuntimeRuntime: correctly traversing this tree : correctly traversing this tree enumerates objects from back to frontenumerates objects from back to front
– Idea: divide space recursively into half-Idea: divide space recursively into half-spaces by choosing spaces by choosing splitting planessplitting planes
Splitting planes can be arbitrarily orientedSplitting planes can be arbitrarily oriented Notice: nodes are always convexNotice: nodes are always convex
![Page 11: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/11.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
![Page 12: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/12.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
![Page 13: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/13.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
![Page 14: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/14.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
![Page 15: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/15.jpg)
David Luebke 11-2-98
BSP TreesBSP Trees
![Page 16: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/16.jpg)
David Luebke 11-2-98
BSP Trees: RenderingBSP Trees: Rendering
renderBSP(BSPtree *T)renderBSP(BSPtree *T)
BSPtree *near, far;BSPtree *near, far;
if (if (T is a leaf nodeT is a leaf node))
renderObject(T)renderObject(T)
if (if (eye on left side of T->planeeye on left side of T->plane))
near = T->left; far = T->right;near = T->left; far = T->right;
else else
near = T->right; far = T->left;near = T->right; far = T->left;
renderBSP(far);renderBSP(far);
renderBSP(near);renderBSP(near);
![Page 17: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/17.jpg)
David Luebke 11-2-98
BSP Trees: RenderingBSP Trees: Rendering
![Page 18: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/18.jpg)
David Luebke 11-2-98
BSP Trees: RenderingBSP Trees: Rendering
![Page 19: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/19.jpg)
David Luebke 11-2-98
BSP Trees: The CatchBSP Trees: The Catch
No bunnies were harmed in my exampleNo bunnies were harmed in my example But what if a splitting plane passes through But what if a splitting plane passes through
an object?an object?– Split the object; give half to each node:Split the object; give half to each node:
– Worst case: can create up to O(nWorst case: can create up to O(n33) objects!) objects!
Ouch
![Page 20: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/20.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray tracingRay tracing
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– Occlusion cullingOcclusion culling
![Page 21: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/21.jpg)
David Luebke 11-2-98
Ray TracingRay Tracing
Idea: Idea: – trace a ray from the eyepoint through trace a ray from the eyepoint through
the center of each pixelthe center of each pixel– Color pixel according to Color pixel according to the first object the first object
the ray hitsthe ray hits– Simple! No need for:Simple! No need for:
Perspective projection matricesPerspective projection matrices ClippingClipping Scan conversion of polygonsScan conversion of polygons
![Page 22: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/22.jpg)
David Luebke 11-2-98
Ray TracingRay Tracing
An example:An example:
ScreenEyepoint Scene
![Page 23: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/23.jpg)
David Luebke 11-2-98
Ray TracingRay Tracing
An example:An example:
ScreenEyepoint Scene
![Page 24: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/24.jpg)
David Luebke 11-2-98
Ray TracingRay Tracing
Two flavors of the algorithm:Two flavors of the algorithm:– Ray castingRay casting just finds visible surfaces just finds visible surfaces– Recursive ray tracingRecursive ray tracing traces additional traces additional
rays from those surfaces for rays from those surfaces for sophisticated shadingsophisticated shading
ShadowsShadows ReflectionReflection RefractionRefraction
![Page 25: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/25.jpg)
David Luebke 11-2-98
Ray Tracing: The CatchRay Tracing: The Catch
Ray tracing is a simple, powerful Ray tracing is a simple, powerful way to determine visibility & shadingway to determine visibility & shading
So why don’t we always use it?So why don’t we always use it?
![Page 26: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/26.jpg)
David Luebke 11-2-98
Ray Tracing: The CatchRay Tracing: The Catch
Ray tracing is a simple, powerful Ray tracing is a simple, powerful way to determine visibility & shadingway to determine visibility & shading
So why don’t we always use it?So why don’t we always use it? Too slow!Too slow!
– Complexity proportional to # of pixelsComplexity proportional to # of pixels– Typical screen: ~1,000,000 pixelsTypical screen: ~1,000,000 pixels– Typical scene:« 1,000,000 polygonsTypical scene:« 1,000,000 polygons
![Page 27: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/27.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray castingRay casting
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– Occlusion cullingOcclusion culling
![Page 28: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/28.jpg)
David Luebke 11-2-98
Conservative AlgorithmsConservative Algorithms
Rendering with a Z-buffer finds Rendering with a Z-buffer finds exact exact visibilityvisibility of of nn polygons in O( polygons in O(nn) time) time
Conservative visibilityConservative visibility algorithmsalgorithms quickly compute a quickly compute a potentially visible potentially visible setset of of vv polygons, polygons, v v « « nn– v v = all visible polygons + a few others= all visible polygons + a few others
Z-buffer can then render this set in Z-buffer can then render this set in O(v) timeO(v) time
![Page 29: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/29.jpg)
David Luebke 11-2-98
View-frustum cullingView-frustum culling
Simple way to quickly reject many Simple way to quickly reject many polygons at once: polygons at once: – Associate simple bounding volumes Associate simple bounding volumes
(e.g., spheres) with each object(e.g., spheres) with each object– Before rendering object, test its Before rendering object, test its
bounding volume for visibilitybounding volume for visibilityPotentially
Visible
Not Visible
![Page 30: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/30.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray castingRay casting
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– Occlusion cullingOcclusion culling
![Page 31: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/31.jpg)
David Luebke 11-2-98
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…
Key observation: cells only see each Key observation: cells only see each other through portals!other through portals!
![Page 32: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/32.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
Idea: Idea: – Create an Create an adjacency graphadjacency graph of cells– Starting with cell containing eyepoint, Starting with cell containing eyepoint,
traverse graph, rendering visible cells traverse graph, rendering 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 Need a Need a line of sightline of sight So cell visibility reduces to testing portal So cell visibility reduces to testing portal
sequences… sequences…
![Page 33: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/33.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
A
D
H
FCB
E
G
H
B C D F G
EA
![Page 34: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/34.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
A
D
H
FCB
E
G
H
B C D F G
EA
![Page 35: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/35.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
A
D
H
FCB
E
G
H
B C D F G
EA
![Page 36: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/36.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
A
D
H
FCB
E
G
H
B C D F G
EA
![Page 37: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/37.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
A
D
H
FCB
E
G
H
B C D F G
EA
![Page 38: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/38.jpg)
David Luebke 11-2-98
Cells & PortalsCells & Portals
Can even figure out which cells a Can even figure out which cells a particular cell will particular cell will nevernever see: see:
Ex: H will Ex: H will nevernever see F; B can see F; B can onlyonly see H see H
This can further speed up cullingThis can further speed up culling
A
D
H
FCB
E
G
![Page 39: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/39.jpg)
David Luebke 11-2-98
OverviewOverview
Recap: visible surfaces; Z-bufferRecap: visible surfaces; Z-buffer Other exact algorithmsOther exact algorithms
– BSP treesBSP trees– Ray castingRay casting
Conservative algorithmsConservative algorithms– View-frustum cullingView-frustum culling– Cells & portalsCells & portals– OcclusionOcclusion cullingculling
![Page 40: Visibility Algorithms for Computer Graphics](https://reader038.vdocuments.mx/reader038/viewer/2022110210/56812ca2550346895d91489b/html5/thumbnails/40.jpg)
David Luebke 11-2-98
Occlusion CullingOcclusion Culling
When cells and portals don’t work…When cells and portals don’t work…– Trees in a forestTrees in a forest– A crowded train stationA crowded train station
Need general Need general occlusion cullingocclusion culling algs: algs:– Dynamic scenes, aggregate occludersDynamic scenes, aggregate occluders– Open problem, little work so far:Open problem, little work so far:
Hierarchical Z-Buffer (Greene 93)Hierarchical Z-Buffer (Greene 93) Hierarchical Occlusion Maps (Zhang 97)Hierarchical Occlusion Maps (Zhang 97)