1 / 29

CS 551 / 645: Introductory Computer Graphics

CS 551 / 645: Introductory Computer Graphics. David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551. Administrivia. Note changes on homework web page We were always drawing the icosahedron inside out…oops. Recap: Visible Surface Determination.

holly
Télécharger la présentation

CS 551 / 645: Introductory Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551 David Luebke 6/5/2014

  2. Administrivia • Note changes on homework web page • We were always drawing the icosahedron inside out…oops David Luebke 6/5/2014

  3. Recap: Visible Surface Determination • Reasons for invisible polygons: • Polygon outside the field of view • Polygon is backfacing • Polygon is occludedby object(s) nearer the viewpoint • Algorithms for determining which potions of which polygons are visible (unoccluded) are known as visible surface algorithms David Luebke 6/5/2014

  4. Recap: Occlusion • For most interesting scenes, some polygons will overlap: • To render the correct image, we need to determine which polygons occlude which David Luebke 6/5/2014

  5. Recap: Painter’s Algorithm • Simple approach: render the polygons from back to front, “painting over” previous polygons: • Doesn’t work in general case • Intersecting polygons • Visibility cycles: David Luebke 6/5/2014

  6. Recap: Binary Space Partition(BSP) Trees • Fuchs et al, 1980 • Assumptions: • Static scene • Moving camera • Commonly used in 3-D video games (e.g., Quake), but going out of style • Still a very powerful, general idea, used in many graphics algorithms David Luebke 6/5/2014

  7. Recap: BSP Trees • Preprocess: overlay a binary (BSP) tree on objects in the scene • Runtime: correctly traversing this tree enumerates objects from back to front • Idea: divide space recursively into half-spaces by choosing splitting planes • Splitting planes can be arbitrarily oriented • Notice: nodes are always convex David Luebke 6/5/2014

  8. Recap: BSP Trees David Luebke 6/5/2014

  9. Recap: BSP Trees David Luebke 6/5/2014

  10. Recap: BSP Trees David Luebke 6/5/2014

  11. Recap: BSP Trees David Luebke 6/5/2014

  12. Recap: BSP Trees David Luebke 6/5/2014

  13. Recap: Rendering BSP Trees renderBSP(BSPtree *T) BSPtree *near, far; if (T is a leaf node) renderObject(T) if (eye on left side of T->plane) near = T->left; far = T->right; else near = T->right; far = T->left; renderBSP(far); renderBSP(near); David Luebke 6/5/2014

  14. Recap: Rendering BSP Trees David Luebke 6/5/2014

  15. Recap: Rendering BSP Trees David Luebke 6/5/2014

  16. Ouch Recap: BSP Tree Cons • No bunnies were harmed in my example • But what if a splitting plane passes through an object? • Split the object; give half to each node: • Worst case: can create up to O(n3) objects! David Luebke 6/5/2014

  17. BSP Demo • Really cool demo: http://symbolcraft.com/pjl/graphics/bsp David Luebke 6/5/2014

  18. Warnock’s Algorithm (1969) • Elegant scheme based on a powerful general approach common in graphics: if the situation is too complex, subdivide • Start with a root viewport and a list of all primitives • Then recursively: • Clip objects to viewport • If number of objects incident to viewport is zero or one, visibility is trivial • Otherwise, subdivide into smaller viewports, distribute primitives among them, and recurse David Luebke 6/5/2014

  19. Warnock’s Algorithm • What is the terminating condition? • How to determine the correct visible surface in this case? David Luebke 6/5/2014

  20. Warnock’s Algorithm • Pros: • Very elegant scheme • Extends to any primitive type • Cons: • Hard to embed hierarchical schemes in hardware • Complex scenes usually have small polygons and high depth complexity • Thus most screen regions come down to the single-pixel case David Luebke 6/5/2014

  21. The Z-Buffer Algorithm • Both BSP trees and Warnock’s algorithm were proposed when memory was expensive • Example: first 512x512 framebuffer > $50,000! • Ed Catmull (mid-70s) proposed a radical new approach called z-buffering. • The big idea: resolve visibility independently at each pixel David Luebke 6/5/2014

  22. The Z-Buffer Algorithm • We know how to rasterize polygons into an image discretized into pixels: David Luebke 6/5/2014

  23. The Z-Buffer Algorithm • What happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel? David Luebke 6/5/2014

  24. The Z-Buffer Algorithm • Idea: retain depth (Z in eye coordinates) through projection transform • Recall canonical viewing volumes (see slide) • Can transform canonical perspective volume into canonical parallel volume with: David Luebke 6/5/2014

  25. The Z-Buffer Algorithm • Augment framebuffer with Z-buffer or depth buffer which stores Z value at each pixel • At frame beginning initialize all pixel depths to  • When rasterizing, interpolate depth (Z) across polygon and store in pixel of Z-buffer • Suppress writing to a pixel if its Z value is more distant than the Z value already stored there • “More distant”: greater than or less than, depending David Luebke 6/5/2014

  26. Interpolating Z • Edge equations: Z is just another planar parameter: z = Ax + By + C • Look familiar? • Total cost: • 1 more parameter to increment in inner loop • 3x3 matrix multiply for setup • See interpolating color discussion from lecture 10 • Edge walking: just interpolate Z along edges and across spans David Luebke 6/5/2014

  27. The Z-Buffer Algorithm • How much memory does the Z-buffer use? • Does the image rendered depend on the drawing order? • Does the time to render the image depend on the drawing order? • How much of the pipeline do occluded polgyons traverse? • What does this imply for the front of the pipeline? • How does Z-buffer load scale with visible polygons? With framebuffer resolution? David Luebke 6/5/2014

  28. 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 6/5/2014

  29. 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 6/5/2014

More Related