On the Fast Construction of Spatial Hierarchies for Ray Tracing PowerPoint PPT Presentation

presentation player overlay
About This Presentation
Transcript and Presenter's Notes

Title: On the Fast Construction of Spatial Hierarchies for Ray Tracing


1
On the Fast Construction of Spatial Hierarchies
for Ray Tracing
  • Vlastimil Havran1,2
  • Robert Herzog1 Hans-Peter Seidel1
  • 1 MPI Informatik, Saarbruecken, Germany
  • 2 Czech Technical University in Prague

2
Talk Outline
  • Previous work
  • H-trees
  • AH-trees
  • Performance results

3
Previous Work
4
Previous Work
  • Kd-trees in O(N log N)
  • Bounding volume hierarchies BVH in O(N log N)
  • Two-level data structures for hierarchical motion
    (Wald et al. 03)
  • Parallel tree traversal (Szecsi et al. 03)
  • Concurrent papers this year (EGSR06, EG06,
    RT06)

5
Approaches to Animated Scenes
  • Set of frames, planned motion or not ?
  • Some objects are moving (1, 50, or 100?)
  • Two Approaches
  • Rebuild data structures from scratch for every
    frame
  • Update data structures for new object positions

6
Most Objects Are Moving .
  • Rebuild from scratch? Why possibly better?
  • High quality of data structures for ray tracing
  • Fast rebuild from scratch is useful in general,
    also for larger static scenes
  • Fast rebuild from scratch has not been addressed
    well in CG publications

7
Spatial Sorting
  • Spatial sorting is a base of ray tracing, it is
    an extension to quicksort.
  • Clearly, sorting is O(N log N)
  • Why then radix-sort is O(N) ?
  • Project goal could we make faster spatial
    sorting in radix-sort like manner?

8
Some Other Issues
  • Definition object 3D geometric primitive,
    which defines a bounding box, and operation
    ray-object intersection (point normal)
  • Binary-Interpolation Search search over the
    monotonically increasing values in array, using
    two phases
  • interpolation search O(log log N)
  • binary search O(log N)

9
Intro to Spatial KD-trees (SKD-trees)
  • Using two splitting planes
  • Proposed by Ooi et al. in 1987 as spatial index
    for objects as extension to kd-trees

Overlapping Configuration
Disjoint Configuration
10
Spatial KD-trees Properties
  • Each object is referenced just once
  • It is not a spatial subdivision (spatial regions
    can overlap)
  • More memory efficient than BVH (only two planes
    in a node, not six planes)
  • Interesting candidate for ray tracing

11
Cost Model for Ray Tracing
Typical cost model for a spatial hierarchy
C C_T C_L C_R C C_TS N_TS
C_LO N_LO C_Access N_Access
  • C_T cost of traversing interior nodes
  • C_L cost of incidence operation in leaves
  • C_R cost of accessing the data from internal or
    external memory

12
Cost Model Based Construction
  • It is also referred to as SAH (surface area
    heuristics)
  • Local greedy decision, where to put splitting
    planes recursion stopping criteria
  • Cost N_L Prob_L N_R Prob_R
  • Probability given by surface area of the box of
    the left and on the right child node
  • Problem is evaluation of N_L and N_R

13
Normalized Cost Function for Many Objects
14
SKD-tree Cost Model
  • Using buckets to find out minimum of the cost (at
    most 100 buckets)
  • Objects are put to buckets according to their
    centroids
  • Recording also minima and maxima of object boxes
    in buckets
  • Sweep-plane algorithm to compute tight left and
    right bounding boxes

15
Performance of Pure SKD-trees
  • It is rather low, not competitive with kd-trees
  • Low performance means too many traversal steps
    and ray-object intersections
  • Need for better bounding of objects
  • A hybrid data structures using bounding
    primitives and SKD-tree nodes

16
How Many Bounding Volume Primitives in 3D ?
  • Assumption axis-aligned bounding planes
  • In total 63 possibilities
  • 1 plane, 6 cases corresponds to kd-tree
  • 2 planes, 15 cases we use only parallel planes
    (3 cases in 3D)
  • 3 planes, 20 cases
  • 4 planes, 15 cases
  • 5 planes, 6 cases
  • 6 planes, 1 case corresponds to BVH

17
H-trees SKD-trees Bounding
Volumes Primitives
Seven types of internal nodes
3 types (x,y,z axis)
1 type (6 planes)
3 types (x,y,z axis)
18
H-trees Construction Algorithm
  • Select an axis (X, or Y, or Z)
  • Decide if to put an bounding node based on the
    cost (details in the paper)
  • Select the number of buckets N (-,10,100)
  • Distribute the objects to the buckets - keep
    minima and maxima in 3 axis in the bucket
  • By sweep-plane compute cost function for all N
    buckets, select minimum cost
  • Distribute the objects into left and right child
  • Recurse until having one object in a node (leaf)

19
H-trees Results
  • Tests on SPD scenes (30 scenes) by Eric Haines
    other 12 scenes of different distributions
  • Used by recursive ray tracing and also only ray
    casting (primary rays)
  • In paper results for only 9 scenes.

20
Reference kd-trees
  • Termination criteria 4 objects in a leaf
  • No split clipping operation
  • O(N log N) complexity
  • Highly optimized C code (but no SSE, no
    multithreading)
  • Construction about 1,0 seconds for 100,000
    objects for 3.5 leaf references per object on a
    PC
  • Ray tracing about 300,000 rays per second for
    completely random rays ( incoherent rays)

21
H-trees Results
  • Parts of the cost model
  • N_TS number of traversal steps
  • N_LO number of ray object intersection tests
  • N_Access number of memory accesses
  • Timings for H-trees construction
  • 2.4 to 12 times faster than kd-trees
  • Timings for tracing rays
  • Comparable with kd-trees

22
AH-trees Motivation
  • Avoid resorting
  • Modification of method Reif and Tate, 1998, for a
    set of points in 3D, achieving time complexity
    O(N log log N)
  • Mimic radix-sort and hence possibly decrease
    complexity
  • Use cost model based on SAH
  • Use H-trees nodes

23
AH-trees Avoiding Resorting
  • Use buckets in 3D uniform grid in 3D
  • Classify objects as small and oversize

Small object allows to limit the object extent
by a box if we know about the presence of an
object in a grid cell
24
AH-trees Construction Algorithm
  • Select a grid resolution, construct grid
  • Classify objects as small and oversize
  • Construct H-trees over small objects in
    predefined position given by 3D grid, in leaves
  • Recurse by AH-trees construction algorithm
  • Recurse by H-trees construction algorithm
  • Create references to a leaf
  • Decide to which level belong oversize objects
  • Create ternary child nodes processing oversize
    objects, creating AH-trees or H-trees

25
AH-trees Ternary child example
26
AH-trees Results
  • Parts of the cost model
  • N_TS number of traversal steps
  • N_LO number of ray object intersection tests
  • N_Access number of memory accesses
  • Timings for AH-trees construction
  • 4 to 20 times faster than kd-trees
  • Timings for tracing rays
  • Up to 4 times slower than kd-trees for skewed
    object distribution
  • Comparable to kd-trees for moderately uniform
    object distribution

27
AH-trees Consideration
  • The deeper in the hierarchy in a single grid, the
    resolution of cost function evaluation is smaller
  • The spatial sorting is approximate using the
    object centroids
  • There is a tradeoff between time complexity for
    construction and ray tracing performance
  • For limited object size O(N log log N)

28
Ray Traversal Algorithm
  • C/C switch for more node types (no problem, CPU
    branch prediction fails anyway)
  • Interval-based technique similar to kd-trees (but
    overlapping intervals)
  • The source code is straightforward
  • For AH-trees the ternary child subtrees are
    traversed first

29
Conclusion
  • Hybrid spatial hierarchy
  • H-trees introduced as SKD-tree nodes bounding
    volume nodes
  • AH-trees as way of approximate sorting for
    H-trees, achieving smaller construction time and
    worse performance (tradeoff)
  • Performance results in the paper

30
Future Work
  • Implementation work ray packets for H-trees
  • Research work tuning between construction time
    and performance for AH-trees
  • Hybrid trees with more types of nodes

31
Take Home Message
  • Efficient ray tracing
  • Efficient spatial hierarchy (tree)
  • Efficient performance cost model
  • Efficient spatial hierarchy
  • top-down construction
  • cost-based model decision (with SAH)
  • termination criteria
  • State of the art ?

32
Poppers model of natural sciences
Karl Popper, 1934 (The Logic of Scientific
Discovery)
real inputs
experiments
design
induction
Falsifiable hypothesis
deduction
implementation
analysis
deduction
Asymptotic bounds
Write a Comment
User Comments (0)
About PowerShow.com