Advanced HSR Methods - PowerPoint PPT Presentation

About This Presentation
Title:

Advanced HSR Methods

Description:

If a BSP tree is used to draw a scene, then all information needed for drawing ... Most HSR methods fall into one of two categories: object-space methods and image ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 16
Provided by: glenngc
Learn more at: https://www.cs.uaf.edu
Category:
Tags: hsr | advanced | methods | scan

less

Transcript and Presenter's Notes

Title: Advanced HSR Methods


1
Advanced HSR Methods
  • Glenn G. ChappellCHAPPELLG_at_member.ams.org
  • U. of Alaska Fairbanks
  • CS 481/681 Lecture Notes
  • Friday, January 30, 2004

2
ReviewQuadtrees 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
C
B
D
E
D
E
A
A
B
C
C
B
E
D
D
E
F
G
G
F
H
I
H
I
3
ReviewQuadtrees Octrees 2/2
  • Handling Observer-Object Interactions
  • Subdivide the quadtree/octree until each leafs
    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 nodes 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.

4
Implementation NotesBSP 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
B
T
B
T
A, T, SB, C, SB, S, T
A, B, C
5
Implementation NotesBSP Trees 2/4
  • Part of the code might look something like this
  • // Add triangle a,b,c to my subtree.
  • void BSPnodeput_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, bc 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

6
Implementation NotesBSP 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 BSPnodeput_inside(const pos a, const pos
    b, const pos c)
  • if (insideptr) // if inside child ptr is not
    null
  • insideptr -gtput_in_tree(a,b,c) //
    recurse
  • else
  • insideptr new BSPtreenode(a,b,c) //
    otherwise, new leaf

7
Implementation NotesBSP 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 Ts 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
8
Implementation NotesQuadtrees 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-gthaschildren() bitmask ! 0U)
  • childsubscript (x mask ? 1 0)
  • (y mask ? 2 0)
  • (z mask ? 4 0)
  • nodeptr nodeptr-gtchildrenchildsubscript
  • mask gtgt 1

9
Advanced HSR MethodsIntroduction
  • 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.

10
Advanced HSR MethodsObject- 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.

11
Advanced HSR MethodsObject- 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.

12
Advanced HSR Methods1. 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.

13
Advanced HSR Methods2. 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.

14
Advanced HSR Methods3. 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.

15
Advanced HSR Methods4. 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.
Write a Comment
User Comments (0)
About PowerShow.com