250 likes | 452 Views
CS 551 / 645: Introductory Computer Graphics. David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551. Recap: Z-Buffer Pros. Simple!!! Easy to implement in hardware Polygons can be processed in arbitrary order Easily handles polygon interpenetration
E N D
CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551 David Luebke 4/2/2014
Recap: Z-Buffer Pros • Simple!!! • Easy to implement in hardware • Polygons can be processed in arbitrary order • Easily handles polygon interpenetration • Enables deferred shading • Rasterize shading parameters (e.g., surface normal) and only shade final visible fragments • When does this help? David Luebke 4/2/2014
Recap: Z-Buffer Cons • Lots of memory (e.g. 1280x1024x32 bits) • Read-Modify-Write in inner loop requires fast memory • Hard to do analytic antialiasing • Hard to simulate translucent polygons • Precision issues (scintillating, worse with perspective projection) David Luebke 4/2/2014
Ray Tracing • Idea: • trace a ray from the eyepoint through the center of each pixel • Color pixel according to the first object the ray hits • Simple! No need for: • Perspective projection matrices • Clipping • Scan conversion of polygons David Luebke 4/2/2014
Ray Tracing • An example: Eyepoint Screen Scene David Luebke 4/2/2014
Ray Tracing • An example: Eyepoint Screen Scene David Luebke 4/2/2014
Ray Tracing • Two flavors of the algorithm: • Ray casting just finds visible surfaces • Recursive ray tracing traces additional rays from those surfaces for sophisticated shading • Shadows • Reflection • Refraction David Luebke 4/2/2014
Ray Tracing: The Catch • Ray tracing is a simple, powerful way to determine visibility & shading • So why don’t we always use it? David Luebke 4/2/2014
Ray Tracing: The Catch • Ray tracing is a simple, powerful way to determine visibility & shading • So why don’t we always use it? • Too slow! • Complexity proportional to # of pixels • Typical screen: ~1,000,000 pixels • Typical scene:« 1,000,000 polygons David Luebke 4/2/2014
Visibility Algorithms • The Z-buffer is an image-space algorithm • Takes place at the end of the pipeline, in screen-space coordinates • BSP Trees are an object-space algorithm • Takes place in world-space coordinates • Warnock’s algorithm is a hybrid • Uses both screen-space and object-space information • How would you classify ray casting? David Luebke 4/2/2014
Visibility Algorithms • The 70’s were the decade of analytic object-space algorithms • In the mid-80’s, memory got cheap enough that Z-buffers became the practical choice • Then history repeated itself… • Next up: conservative visibility algorithms for reducing load from the front end of the rendering pipeline David Luebke 4/2/2014
Conservative Visibility Agorithms • View-frustum culling • Organize primitives into clumps with a simple bounding volume • Before rendering the primitives in a clump, test its 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, render normally • If the clump is entirely within the view frustum, can render with clipping disabled David Luebke 4/2/2014
Efficient View-Frustum Culling • How big should the clumps be? • Choose minimum size so:cost testing bounding volume << cost clipping primitive • Organize bounding volumes into a hierarchy for more efficient testing • A general strategy known as hierarchical bounding volumes David Luebke 4/2/2014
Efficient View-Frustum Culling • What shape should bounding volumes be? • Spheres and axis-aligned bounding boxes are simple to calculate and cheap to test • Oriented bounding boxesconverge asymptotically faster in theory • Lots of other volumes have been proposed, but most people still use spheres and AABBs. David Luebke 4/2/2014
Efficient View-Frustum Culling • Where in the pipeline should view-frustum culling be performed? • As early as possible (world coordinates) David Luebke 4/2/2014
Cells & Portals • Goal: walk through architectural models (buildings, cities, catacombs…) • These divide naturally into cells • Rooms, alcoves, corridors… • Transparent portalsconnect cells • Doorways, entrances, windows… • Key observation: cells only see each other through portals! David Luebke 4/2/2014
Cells & Portals • Idea: • 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 • Need a line of sight • So cell visibility reduces to testing portal sequences… David Luebke 4/2/2014
Cells & Portals A D E F B C G H A E B C D F G H David Luebke 4/2/2014
Cells & Portals A D E F B C G H A E B C D F G H David Luebke 4/2/2014
Cells & Portals A D E F B C G H A E B C D F G H David Luebke 4/2/2014
Cells & Portals A D E F B C G H A E B C D F G H David Luebke 4/2/2014
Cells & Portals A D E F B C G H A E B C D F G H David Luebke 4/2/2014
Cells & Portals • Can even figure out which cells a particular cell will never see: Ex: H will never see F; B can only see H • This can further speed up culling A D E F B C G H David Luebke 4/2/2014
Overview • Recap: visible surfaces; Z-buffer • Other exact algorithms • BSP trees • Ray casting • Conservative algorithms • View-frustum culling • Cells & portals • Occlusionculling David Luebke 4/2/2014
Occlusion Culling • When cells and portals don’t work… • Trees in a forest • A crowded train station • Need general occlusion culling algs: • Dynamic scenes, aggregate occluders • Open problem, little work so far: • Hierarchical Z-Buffer (Greene 93) • Hierarchical Occlusion Maps (Zhang 97) David Luebke 4/2/2014