Ray Tracing Acceleration (5)
Ray Tracing Acceleration Techniques Too Slow! Uniform grids Spatial hierarchies K-D Octtree BSP Hierarchical grids Hierarchical bounding volumes (HBV) Tighter bounds Faster intersector Early ray termination Adaptive sampling Beam tracing Cone tracing Pencil tracing Faster intersection N1 Fewer raysGeneralized rays
Roadmap (LRT book, ch 4 – Intersection Acceleration) Approaches To Reducing Intersections –Ray-Box Intersections –Regular Grid –Hierarchical bounding volumes –BSP trees and friends –Meta-Hierarchies –Refinements to basic approaches Hierarchical Grid Accelerator –Creation –Traversal Kd Tree –Tree Representation –Tree construction –Traversal Further Reading
Grids 3-D array of cells Each cell contains list of all objects it intersects Ray intersected with all objects in a given cell’s list Cells visited in Bresenham order
Bounding Volume Hierarchies
Hierarchical Bounding Volumes (HBV) Trees of bounding volumes are constructed in a similar way to spatial hierarchy HBV does not partition space: the bounding volumes can overlap each other. HBV can be created from existing model hierarchy or by running a clustering algorithm.
Bounding Volume Ray-bunny intersection takes 70K ray-triangle intersections even if ray misses the bunny Place a sphere around bunny –Ray A misses sphere so ray A misses bunny without checking 70K ray-triangle intersections –Ray B intersects sphere but still misses bunny after checking 70K intersections –Ray C intersects sphere and intersects bunny Can also use axis-aligned bounding box –Easier to create for triangle mesh A B C
Bounding Volume Hierarchy Associate bounding volume with each node of scene graph If ray misses a node’s bounding volume, then no need to check any node beneath it If ray hits a node’s BV, then replace it with its children’s BV’s (or geometry) Breadth first search of tree –Maintain heap ordered by ray- BV intersection t-values –Explore children of node w/least pos. ray-BV t-value A B C Bunny BV Body BV Head BV L.EarFaceR.Ear BV
Choosing Bounding Volumes
Hierarchical Bounding Volumes
Heuristics for an Effective Bounding Hierarchy
Bounding Volume Hierarchy
Find bounding box of objects
Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups
Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse
Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse
Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse
Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse
Where to split objects? At midpoint OR Sort, and put half of the objects on each side OR Use modeling hierarchy
Intersection with BVH Check subvolume with closer intersection first
Intersection with BVH Don't return intersection immediately if the other subvolume may have a closer intersection
Hierarchical Bounding Volumes Create tree of bounding volumes Children are contained within parent Creation preprocess –From model hierarchy –Automatic clustering Search intersect(node,ray,hits) { if( intersectp(node->bound,ray) if( leaf(node) ) intersect(node->prims,ray,hits) else for each child intersect(child,ray,hits) }
Bounding Volume Hierarchy Discussion Advantages –easy to construct –easy to traverse –binary Disadvantages –may be difficult to choose a good split for a node –poor split may result in minimal spatial pruning
Ray Tracing Acceleration Techniques Too Slow! Uniform grids Spatial hierarchies K-D Octtree BSP Hierarchical grids Hierarchical bounding volumes (HBV) Tighter bounds Faster intersector Early ray termination Adaptive sampling Beam tracing Cone tracing Pencil tracing Faster intersection N1 Fewer raysGeneralized rays
Uniform Spatial Partition
Spatial Partition Structures
Pitfalls!
3-d Trees (K-d Trees)
Octrees
BSP Trees
Ray Tracing BSP Trees
Wrap-up Uniform Grids, Spatial Hierarchies, Hierarchical Grids, HBVs Question: Which one of the above is best? Answer: I don’t know. Here all techniques are heuristics.
Wrap-up Vlastimil Havran’s Best E.ciency Scheme Project at compares different accelerators. Basically every one of them works better in some cases and worse in some other cases. Worst case for ”Uniform Grid” is sparse scenes, –for example, a very complicated bunny model put at the center of a huge stadium.