1 / 15

Advanced HSR Methods

Advanced HSR Methods. Glenn G. Chappell CHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004. Review: Quadtrees & Octrees [1/2]. The root node of a quadtree corresponds to a square region in space.

Download Presentation

Advanced HSR Methods

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. Advanced HSR Methods Glenn G. ChappellCHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004

  2. 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 A A B C B C D E D E A A B C B C D E D E F G F G H I H I CS 481/681

  3. 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. CS 481/681

  4. 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. S S C C C A A A B T B T B A, B, C A, T, SB, C, SB, S, T CS 481/681

  5. 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 CS 481/681

  6. 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 } CS 481/681

  7. 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 CS 481/681

  8. 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; } CS 481/681

  9. 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. CS 481/681

  10. 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. CS 481/681

  11. 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. CS 481/681

  12. 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. CS 481/681

  13. 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. CS 481/681

  14. 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. CS 481/681

  15. 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. CS 481/681

More Related