Advanced HSR Methods Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Collisions and Intersections When objects move, test for collision. When projecting surfaces, check for intersections. (Many slides adapted from Amitabh.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
More HSR, OpenGL Buffers & Tests Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 2, 2004.
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
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
Visibility Culling. Back face culling View-frustrum culling Detail culling Occlusion culling.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Computer Graphics 14: Surface Detection Methods
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.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Hidden Surface Removal
BSP Trees, Quadtrees & Octrees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January 28, 2004.
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
Graphics Pipeline Hidden Surface CMSC 435/634. Visibility We can convert simple primitives to pixels/fragments How do we know which primitives (or which.
Computer Graphics Mirror and Shadows
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 25 of 41 William H. Hsu Department of Computing.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
CS 450: COMPUTER GRAPHICS VISIBLE SURFACE DETECTION SPRING 2015 DR. MICHAEL J. REALE.
Polygon Lists & 3-D File Formats Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 18, 2002.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Implementing Scene Graphs, CSG Trees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, January 26, 2004.
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.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
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,
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
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.
Visible-Surface Detection Methods
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
1 3D Hidden Surface Removal 김 성 남. 2 Contents Goal Motivation Approaches - back face detection - depth buffer - A-buffer - Scan line - Depth.
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 Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
Computer Graphics I, Fall 2010 Implementation II.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Accumulation-Based Effects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, February 4, 2004.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture 30: Visible Surface Detection
Stenciling Effects Glenn G. Chappell
Computer Graphics Shading in OpenGL
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Quadtrees 1.
Projection in 3-D Glenn G. Chappell
Lecture 13 Clipping & Scan Conversion
Presentation transcript:

Advanced HSR Methods Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004

30 Jan 2004CS 481/6812 Review: Quadtrees & Octrees [1/2] The root node of a quadtree corresponds to a square region in space. Generally, this encompasses the entire “region of interest”. If desired, subdivide along lines parallel to the coordinate axes, forming four smaller identically sized square regions. The child nodes correspond to these. Some or all of these children may be subdivided further. Octrees work in a similar fashion, but in 3-D, with cubical regions subdivided into 8 parts. A A CBD E A CB E GFH I D A BC DE FG HI A A BC DE

30 Jan 2004CS 481/6813 Review: Quadtrees & Octrees [2/2] Handling Observer-Object Interactions Subdivide the quadtree/octree until each leaf’s region intersects only a small number of objects. Each leaf holds a list of pointers to objects that intersect its region. Find out which leaf the observer is in. We only need to test for interactions with the objects pointed to by that leaf. Inside/Outside Tests for Odd Shapes The root node represent a square containing the shape. If a node’s region lies entirely inside or entirely outside the shape, do not subdivide it. Otherwise, do subdivide (unless a predefined depth limit has been exceeded). Then the quadtree or octree contains information allowing us to check quickly whether a given point is inside the shape. Sparse Arrays of Spatially-Organized Data Store array data in the quadtree or octree. Only subdivide if that region of space contains interesting data. This is how an octree is used in the BLUIsculpt program.

30 Jan 2004CS 481/6814 Implementation Notes: BSP Trees [1/4] A BSP tree that holds only triangles can be simpler to implement than one that handles more general polygons. Note however, that a triangle splits naturally into a triangle and a quadrilateral. If a triangle is to split into triangles only, then it must split into three facets, not two. A C B A C B S T A, T, S B, C, S B, S, T A C B S T A, B, C

30 Jan 2004CS 481/6815 Implementation Notes: BSP Trees [2/4] Part of the code might look something like this: // Add triangle a,b,c to my subtree. void BSPnode::put_in_tree(const pos & a, const pos & b, const pos & c) { […] // check inside/outside for a,b,c switch (results of above) { case [a,b,c inside] : put_inside(a,b,c); break; case [a outside, b&c inside] : const pos s = […] ; // point between a,c const pos t = […] ; // point between a,b put_outside(a,t,s); put_inside(b,c,s); put_inside(b,s,t); break; […] // 6 more cases

30 Jan 2004CS 481/6816 Implementation Notes: BSP Trees [3/4] Here is put_inside. Function put_outside would be similar. // Add triangle a,b,c to my subtree. Put it on the INSIDE of me. void BSPnode::put_inside(const pos & a, const pos & b, const pos & c) { if (insideptr) // if inside child ptr is not null insideptr ->put_in_tree(a,b,c); // recurse else insideptr = new BSPtreenode(a,b,c); // otherwise, new leaf }

30 Jan 2004CS 481/6817 Implementation Notes: BSP Trees [4/4] Two good points were brought up in class: If a BSP tree is used to draw a scene, then all information needed for drawing needs to be accessible from the tree. You might want to store colors in each BSP-tree node. Facet normals are easily computed, but not vertex normals. When splitting a triangle, how to find new vertex normals? Say T is a new point on the segment from A to B. To find T’s normal, lirp between the normals for A and B, and normalize. With vecpos.h, we can find T as before: double k1 = dot(A-p1, N); // n is the normal of the double k2 = dot(B-p1, N); // facet that makes us split pos T = affinecomb(k2, A, -k1, B); Suppose that AN and BN are the normals at A and B, respectively. We compute TN (the normal for T) as follows: vec TN = affinecomb(k2, AN, -k1, BN).normalized(); N A T B

30 Jan 2004CS 481/6818 Implementation Notes: Quadtrees & Octrees When dealing with octrees (and quadtrees) it is convenient to let coordinates be integers. Then we can select child pointers using bit masking. Octreenode * nodeptr = root; unsigned int mask = 0x8000U; // or whatever... while (nodeptr->haschildren() && bitmask != 0U) { childsubscript = (x & mask ? 1 : 0) + (y & mask ? 2 : 0); + (z & mask ? 4 : 0); nodeptr = nodeptr->children[childsubscript]; mask >>= 1; }

30 Jan 2004CS 481/6819 Advanced HSR Methods: Introduction Now we consider various HSR methods. HSR = Hidden Surface Removal. We use this term even when dealing with points & lines. HSR is closely related to translucency. HSR deals with the opaque case. Degrees of opacity require more general (but often similar) methods. When we deal with translucent surfaces, we often use color blending. In this case, we need to draw back-to-front. We will discuss blending in our buffers/tests/blending unit, which begins next week.

30 Jan 2004CS 481/68110 Advanced HSR Methods: Object- vs. Image-Space [1/2] Most HSR methods fall into one of two categories: object-space methods and image-space methods. Object-Space Methods Here, we do HSR before rasterization. Often outside the pipeline entirely. We deal with scene descriptions (polygons?). Image-Space Methods Here, we deal with fragments or pixels. Thus, if part of a pipeline, image-space methods generally come during or after rasterization.

30 Jan 2004CS 481/68111 Advanced HSR Methods: Object- vs. Image-Space [2/2] General advantages of object-space methods: Image-space methods are limited by frame-buffer resolution, while object- space methods are not. So output from an object-space method can look smoother than that from image-space methods. Since object-space methods generally come before the pipeline, they can sometimes be used as a one-time preprocessing step, to generate information to be used in rendering a number of frames. If an image-space method works with the pipeline, then it comes in or after rasterization, and so cannot be used for preprocessing. General advantages of image-space methods: Image-space methods usually require less knowledge about the scene. Thus, they have more general applicability and work better with a pipeline. Object- space methods can require certain types of scene organization, so they are more special-purpose. Object-space methods usually require comparisons between pairs of polygons. Thus, they can be too slow for complex scenes. (This also means that they do not fit well in the pipeline, which works on polygons one at a time.) Image- space methods generally work on polygons one-by-one, which is generally more efficient. We look at specific image-space methods today. Next time, we will look at specific object-space methods.

30 Jan 2004CS 481/68112 Advanced HSR Methods: 1. Z-Buffering This is the method you already know about. Z-buffering is the general term for what OpenGL does with its depth buffer (“z-buffer”). It is therefore often called “depth buffering” in OpenGL- speak. Properties Image-space method. “Main loop” runs over polygons. Right? Works well with pipeline architectures. Requires no knowledge of scene structure. Thus: Very general. Does not work well with translucency.

30 Jan 2004CS 481/68113 Advanced HSR Methods: 2. A-Buffering This is not covered in the text. An A-buffer holds, for each pixel, a list of the fragments drawn there, in back-to-front order. Each has a color, a depth, a translucency(?), and possibly other properties. The A-buffer sits at the end of the pipeline. Once the “normal” render phase is complete, a second phase happens, which creates the image from the A-buffer data. Properties Image-space method. “Main loop” runs over polygons. Works well with pipeline architectures. Requires no knowledge of scene structure. Works well with translucency. Thus: Very, very general. But, very high overhead. Usually not worth it.

30 Jan 2004CS 481/68114 Advanced HSR Methods: 3. Ray Casting Given a pixel, find its color by projecting a ray through it, to the scene. See what it hits first. The other stuff it might have hit is hidden. Ray tracing is a fancier version. Properties Image-space method. “Main loop” runs over pixels. Does not work well with pipeline architectures. Requires a scene description. Thus: Not very general. Works with translucency. But it slows down.

30 Jan 2004CS 481/68115 Advanced HSR Methods: 4. Scan-Line Method For each scan line in the frame buffer: Go from left to right. Keep a list of polygons (and their depths) that hit the current pixel. When an edge is crossed, add or subtract a polygon from the list. When advancing to the next pixel, adjust the depths of all polygons. Properties Image-space method. “Main loop” runs over scan lines. Does not work well with pipeline architectures. Requires a scene description. Thus: Not very general. Can work well with translucency with a little adjustment.