Download presentation
1
Ray Tracing Acceleration (3)
2
Ray Tracing Acceleration Techniques
Too Slow! Faster intersection Fewer rays Generalized rays N 1 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
3
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 Further Reading
4
Spatial Data Structures
Create a data structure aware of the spatial relations Partition space and place objects within subregions Only consider subregions that the ray passes through Avoid computing intersections twice if object lies inside multiple subregions
5
Spatial Decompositions:
Focus on spatial data structures that partition space into regions, or cells, of some type Generally, cut up space with planes that separate regions Always based on tree structures
6
Tree-structure Hierarchy: Variations
KD tree Quadtree (2D) Octree (3D) BSP tree
7
Spatial Decompositions: Tree-structure Hierarchy
Kd-trees: Axis aligned planes, in alternating directions, cut space into rectilinear regions
8
Spatial Decompositions: Tree-structure Hierarchy
Octrees (Quadtrees): Axis aligned, regularly spaced planes cut space into cubes (squares)
9
Spatial Decompositions: Tree-structure Hierarchy
BSP Trees: Arbitrarily aligned planes cut space into convex regions
10
Creating Spatial Hierarchies
insert(node,prim) { if( overlap(node->bound,prim) ) if( leaf(node) ) { if( node->nprims > MAXPRIMS && node->depth < MAXDEPTH ) { subdivide(node); foreach child in node insert(child,prim) } else list_insert(node->prims,prim); else // Typically MAXDEPTH=16, MAXPRIMS=2-8
11
K-d trees (K-dimensional)
12
K-d trees An axis-aligned plane is introduced to break down each volume into two sub-volumes. The subdivision stops when the number of objects overlapping a cell falls below a certain threshold. As in uniform grid, objects must be assigned to cells.
13
A A Leaf nodes correspond to unique regions in space
14
A B A Leaf nodes correspond to unique regions in space
15
A B B A Leaf nodes correspond to unique regions in space
16
C A B B A
17
C A B C B A
18
C A D B C B A
19
C A D B C B D A
20
K-d tree (Spatial Hierarchies)
B B C C D A Leaf nodes correspond to unique regions in space
21
Kd-tree Example 4 6 1 10 8 2 3 11 3 13 2 4 5 6 7 12 8 9 10 11 12 13 9 5 1 7
22
Heuristics on where to put the partitioning plane
Median-cut: .find the plane that puts approximately equal number of objects at each side.
23
Heuristics on where to put the partitioning plane: Median-Cut
Find the plane that puts approximately equal number of objects at each side. Build hierarchy bottom-up Chose direction and position carefully Surface-area heuristic
24
Heuristics on where to put the partitioning plane: Surface Area and Rays
The number of rays in a given direction that hits the object is proportional to the projected area A.
25
Crofton’s Theorem states that
Heuristics on where to put the partitioning plane: Surface Area and Rays And rays in all directions that hits the object is proportional to the surfaces area S. Crofton’s Theorem states that is average projected area in all directions.
26
Crofton’s theorem: For a convex body: Example: Sphere
Heuristics on where to put the partitioning plane: Surface Area and Rays Crofton’s theorem: For a convex body: Example: Sphere
27
Heuristics on where to put the partitioning plane: Surface Area and Rays
Probability of a ray hitting an object that is completely inside a cell is:
28
K-d tree (Spatial Hierarchies)
B B C C D A Point location by recursive search
29
Search for C A D B C B D A
30
Search for Left or Right of partition plane A? C A D B C B D A
31
Search for C A Left or Right of partition plane B? D B C B D A
32
Search for C A D B Left or Right of partition plane C? C B D A
33
Point location by recursive search
FOUND ! C A D B C B D A Point location by recursive search Leaf nodes correspond to unique regions in space
34
Ray Traversal Algorithms
tmin, tmax are near and far intersection points of the ray with the current volume; t* is the intersection of ray with partitioning plane.
35
Ray Traversal Algorithms
Recursive inorder traversal Kaplan, Arvo, Jansen Intersect(L,tmin,tmax) Intersect(L,tmin,t*) Intersect(R,t*,tmax) Intersect(R,tmin,tmax)
36
Ray Traversal Algorithms
The previous slide applies for ray going to the right. The dot product of ray direction with plane normal r · n tells where the ray is going with respect to the plane.
37
3-d Trees (K-d Trees)
38
Tree-structure Hierarchy: Variations
Similarly, we can construct quadtree, octree, etc. In BSP tree, the partitioning plane is not necessarily axis-aligned As in uniform grid, objects must be assigned to cells KD tree Quadtree (2D) Octree (3D) BSP tree
39
Other Partitioning Structures
Octree Ray can parse through large empty areas Requires less space than grid Subdivision takes time Binary Space Partition (BSP) Tree Planes can divide models nearly in half Trees better balanced, shallower Added ray-plane intersections
40
octree
41
Octrees
42
Octrees
44
BSP Example 1 1 2 2 4 A 3 out 5 7 3 A out B 6 8 out 6 5 C B C out D out Notes: Splitting planes end when they intersect their parent node’s planes Internal node labeled with planes, leaf nodes with regions D 4 8 7
45
BSP Example
47
BSP Trees
48
Ray Tracing BSP Trees
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.