Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
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.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
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,
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.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
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.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
Hidden Surface Removal
Visible Surface Determination
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
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.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
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.
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
Hidden Surface Removal
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.
David Luebke 1 12/8/2015 Visibility CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
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.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
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.
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Visibility Visibility.
Visible Surface Detection
Computer Graphics Implementation II
Visibility Week 9, Fri 31 Oct 2003
Hidden Surfaces Dr. Scott Schaefer.
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
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.)
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007

Hierarchical structure Data usually contains coherent regions of cells with similar properties hierarchical spatial enumeration encode the coherence in the volume data. Is actually nothing more then a data structure built by recursive subdivision. if a parent is not important then it's children aren't either.

Quadtrees Efficient storage of 2D data Completely non-important regions are represented by one cell; recursive subdivision done on others

Octrees Counterpart of Quadtree in 3D Each node has eight children instead of four

Recursive Subdivision Recursive function for empty region construction: for m=1,2….M

Case study: quad-tree in ray casting Also, in isosurface extraction. Min and Max value range

Hidden Surface Removal (HSR) Why might a polygon be invisible?  outside the field of view  backfacing  occluded by object(s) closer to the viewpoint we want to avoid spending time on these invisible polygons

Back-Face Culling Most objects are opaque. Avoid drawing any portion of an object that lies behind an opaque object, as seen from the camera’s point of view.  Back-face removal algorithm: polygons  whose normals point away from the camera are always occluded There is only a single object, and can fail if the object is not convex. Reduces by about half the number of polygons to be considered for each pixel. Every front-facing polygon must have a corresponding rear-facing one

Occlusion For a scene consists of a sequence of intersecting objects. Correct occlusion relationship is required in order to render correct image.

Painter’s algorithm Draw polygons as an oil painter might: The farthest one first. Render the object from the back to front. Problem arise when no explicit visibility order can be found by forming a relationship cycle.

Binary Space Partition Trees BSP tree: traversed in a systematic way to draw the scene with HSR  Preprocess: organize all of polygons (hence partition) into a binary tree data structure  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

BSP Arbitrary plane split the space into two half-spaces:  Outside: the side pointed to by the outward- pointing normal to the plan  Inside: the other half-space Inside ones Outside ones

BSP Trees: Objects

Rendering BSP Trees RenderBSP(BSPtree *T) BSPtree *near, *far; if (T is a leaf node) RenderObject(T) if (eye on inside side of T->plane) near = T->left; far = T->right; else near = T->right; far = T->left; RenderBSP(far); RenderBSP(near);

Rendering BSP Trees

BSP Tree Construction Split along the space defined by any plane Classify all polygons into left or right half-space of the plane  If a polygon intersects plane, split polygon into two and classify them both Recurse down the left half-space Recurse down the right half-space

No bunnies were harmed in previous example But what if a splitting plane passes through an object?  Split the object; give half to each node Discussion: BSP Tree Cons Ouch

Summary: BSP Trees Pros:  Preprocess done once  Only writes to framebuffer (no reads to see if current polygon is in front of previously rendered polygon, i.e., painters algorithm) Cons:  Computationally intense preprocess stage  Slow time to construct tree  Splitting increases polygon count

The Z-Buffer Algorithm Both BSP trees and Warnock’s algorithm (subdivide primitive into viewports in a recursive way) 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

The Z-Buffer Algorithm We know how to rasterize polygons into an image discretized into pixels:

The Z-Buffer Algorithm What happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel?

The Z-Buffer Algorithm Idea: retain depth (Z in eye coordinates) through projection transform  Use canonical viewing volumes  Each vertex has z coordinate (relative to eye point) intact

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

Interpolating Z Edge equations: Z is just another planar parameter: z = (-D - Ax – By) / C If walking across scanline by (  x) z new = z old – (A/C)(  x)  Look familiar?  Total cost: 1 more parameter to increment in inner loop 3x3 matrix multiply for setup Edge walking: just interpolate Z along edges and across spans

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

Z-Buffer Cons Lots of memory (e.g. 1280x1024x32 bits)  With 16 bits cannot discern millimeter differences in objects at 1 km distance Read-Modify-Write in inner loop requires fast memory Hard to do analytic antialiasing  We don’t know which polygon to map pixel back to Hard to simulate translucent polygons  We throw away color of polygons behind closest one

Reference Slides from David Brogan at University of Virginia