David Luebke 1 12/8/2015 Visibility CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

Slides:



Advertisements
Similar presentations
Computer Graphics Inf4/MSc 28/10/08Lecture 91 Computer Graphics Lecture 9 Visible Surface Determination Taku Komura.
Advertisements

CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
Graphics Pipeline.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Visible Surface Determination.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
CS 551 / 645: Introductory Computer Graphics Visible Surface Determination.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
CS 445 / 645: Introductory Computer Graphics
UBI 516 Advanced Computer Graphics
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility II Week 7,
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Hidden Surfaces II Week.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Visibility Week 9, Fri 31 Oct 2003.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility Week 7, Wed.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Visibility: Z Buffering Week 10, Mon 3 Nov 2003.
Hidden Surface Removal
Visible Surface Determination
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Clipping II, Hidden Surfaces.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
CAP4730: Computational Structures in Computer Graphics
3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer)
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Zhen Jiang West Chester University.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Hidden Surfaces University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Hidden Surfaces / Depth Test University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Hidden Surface Removal. 2 Goal: Determine which surfaces are visible and which are not. Z-Buffer is just one of many hidden surface removal algorithms.
Lecture 30: Visible Surface Detection
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Visibility Visibility.
Visible Surface Detection
Visibility Week 9, Fri 31 Oct 2003
CSC418 Computer Graphics Back Faces Visibility Algorithms.
Hidden Surfaces Dr. Scott Schaefer.
CSCE 441: Computer Graphics Hidden Surface Removal
Visibility: Z Buffering Week 10, Mon 3 Nov 2003
Hidden Surfaces II Week 9, Mon Mar 15
Hidden Surface Removal
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Presentation transcript:

David Luebke 1 12/8/2015 Visibility CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003

David Luebke 2 12/8/2015 Admin ● Assignment 3 ■ Postponed to Wed Mar 26 ■ Minor changes made as detailed in ■ Do the Phong model first, then the Blinn model for (a little) extra credit ○ Difference is described nicely in textbook Ch 14. ● I’ll be leaving town…schedule in flux, stay tuned

David Luebke 3 12/8/2015 Recap: Visibility ● Why might a polygon be invisible? ■ Polygon outside the field of view ■ Polygon is backfacing ■ Polygon is occluded by object(s) nearer the viewpoint ■ Other reasons: ○ Too small to be seen ○ Obscured by fog or haze ○ Too transparent ○ Too dark ● For both efficiency and correctness reasons, we need to know when polygons are invisible

David Luebke 4 12/8/2015 Recap: Back-Face Culling ● On the surface of a closed manifold, polygons whose normals point away from the camera are always occluded: Note: backface culling alone doesn’t solve the hidden-surface problem!

David Luebke 5 12/8/2015 Recap: Back-Face Culling ● By not rendering backfacing polygons, we improve performance by roughly 2x ● Can only use backface culling when objects are known to be solid ■ Closed, orientable manifolds ■ Meaning “well behaved” meshes that partition space into “inside” and “outside” the object ● In practice, performed by transforming vertices and testing clockwise or counter-clockwise screen order ■ In principle, happens after xform, before lighting & rasterization ■ In practice, xform & lighting are linked

David Luebke 6 12/8/2015 Recap: Painter’s Algorithm ● Simple approach: render the polygons from back to front, “painting over” previous polygons: ■ Draw blue, then green, then pink

David Luebke 7 12/8/2015 Painter’s Algorithm: Problems ● Intersecting polygons present a problem ● Even non-intersecting polygons can form a cycle with no valid visibility order:

David Luebke 8 12/8/2015 Recap: Analytic Visibility Algorithms ● Early visibility algorithms computed the set of visible polygon fragments directly, then rendered the fragments to a display:

David Luebke 9 12/8/2015 Recap: Analytic Visibility Algorithms ● Minimum worst-case cost of computing the fragments for a scene composed of n polygons: O(n 2 )

David Luebke 10 12/8/2015 Binary Space Partition Trees (1979) ● BSP tree: organize all of space (hence partition) into a binary tree ■ Preprocess: overlay a binary 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 11 12/8/2015 BSP Trees: Objects

David Luebke 12 12/8/2015 BSP Trees: Objects

David Luebke 13 12/8/2015 BSP Trees: Objects

David Luebke 14 12/8/2015 BSP Trees: Objects

David Luebke 15 12/8/2015 BSP Trees: Objects

David Luebke 16 12/8/2015 Rendering BSP Trees renderBSP(BSPtree *T) BSPtree *near, far; if (eye on left side of T->plane) near = T->left; far = T->right; else near = T->right; far = T->left; renderBSP(far); if (T is a leaf node) renderObject(T) renderBSP(near);

David Luebke 17 12/8/2015 Rendering BSP Trees

David Luebke 18 12/8/2015 Rendering BSP Trees

David Luebke 19 12/8/2015 Polygons: BSP Tree Construction ● Split along the plane containing any polygon ● Classify all polygons into positive or negative half- space of the plane ■ If a polygon intersects plane, split it into two ● Recurse down the negative half-space ● Recurse down the positive half-space

David Luebke 20 12/8/2015 Polygons: BSP Tree Traversal ● Query: given a viewpoint, produce an ordered list of (possibly split) polygons from back to front: BSPnode::Draw(Vec3 viewpt) Classify viewpt: in + or - half-space of node->plane? // Call that the “near” half-space farchild->draw(viewpt); render node->polygon; // always on node->plane nearchild->draw(viewpt); ● Intuitively: at each partition, draw the stuff on the farther side, then the polygon on the partition, then the stuff on the nearer side

David Luebke 21 12/8/2015 Discussion: 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(n 3 ) objects! Ouch

David Luebke 22 12/8/2015 BSP Trees ● A BSP Tree increases storage requirements by splitting polygons ■ What is the worst-case storage cost of a BSP tree on n polygons? ● But rendering a BSP tree is fairly efficient ■ What is the expected cost of a single query, for a given viewpoint, on a BSP tree with m nodes?

David Luebke 23 12/8/2015 BSP Demo ● Nice demo: ■ ■ Also has a link to the BSP Tree FAQ

David Luebke 24 12/8/2015 Summary: BSP Trees ● Pros: ■ Simple, elegant scheme ■ Only writes to framebuffer (i.e., painters algorithm) ○ Thus once very popular for video games (but no longer, at least on PC platform) ○ Still very useful for other reasons (more later)

David Luebke 25 12/8/2015 Summary: BSP Trees ● Cons: ■ Computationally intense preprocess stage restricts algorithm to static scenes ■ Worst-case time to construct tree: O(n 3 ) ■ Splitting increases polygon count ○ Again, O(n 3 ) worst case

David Luebke 26 12/8/2015 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 27 12/8/2015 Warnock’s Algorithm ● What is the terminating condition? ● How to determine the correct visible surface in this case?

David Luebke 28 12/8/2015 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 29 12/8/2015 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 ■ (He went on to help found a little company named Pixar) ● The big idea: resolve visibility independently at each pixel

David Luebke 30 12/8/2015 The Z-Buffer Algorithm ● We know how to rasterize polygons into an image discretized into pixels:

David Luebke 31 12/8/2015 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 32 12/8/2015 The Z-Buffer Algorithm ● Idea: retain depth (Z in eye coordinates) through projection transform ■ Recall canonical viewing volumes ■ Can transform canonical perspective volume into canonical parallel volume with:

David Luebke 33 12/8/2015 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 34 12/8/2015 ● 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: can interpolate Z along edges and across spans Interpolating Z

David Luebke 35 12/8/2015 The Z-Buffer Algorithm ● To think about: ■ 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?