ray tracing 2: acceleration
Post on 19-Jan-2016
46 Views
Preview:
DESCRIPTION
TRANSCRIPT
CS 445Greg Humphreys, Spring 2003
Ray Tracing 2:Acceleration
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Ray Tracing Acceleration Techniques
Too Slow!
Uniform gridsSpatial hierarchies•K-D•Octtree•BSPHierarchical gridsHierarchical bounding volumes (HBV)
Tighter boundsFaster intersector
Early ray terminationAdaptive sampling
Beam tracingCone tracingPencil tracing
Faster intersection
N 1
Fewer rays Generalized rays
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Uniform GridsPreprocess scene1. Find bounding box
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Uniform GridsPreprocess scene1. Find bounding box2. Determine grid
resolution3 | |n d O
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Uniform GridsPreprocess scene1. Find bounding box2. Determine grid
resolution
3. Place object in cell if its bounding box overlaps the cell
3 | |n d O
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Uniform GridsPreprocess scene1. Find bounding box2. Determine grid
resolution
3. Place object in cell if its bounding box overlaps the cell
4. Check that object overlaps cell (expensive!)
3 | |n d O
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Uniform GridsPreprocess sceneTraverse grid
3D line = 3D-DDA6-connected line
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Caveat: OverlapOptimize objects that overlap multiple cellsCaveat 1 (correctness):
Intersection must lie within current cell
Caveat 2 (efficiency):Redundant intersection tests“Mailboxes” Assign each ray a number Object intersection cache (“mailbox”)
• Store ray number, intersection information
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Spatial Hierarchies
A
B C
D
A
B
C
D
Leaf nodes correspond to unique regions in space
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Spatial Hierarchies
A
B C
D
A
B
C
D
Point location by recursive search
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Variations
KD tree octtree BSP tree
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Creating Spatial Hierarchiesinsert(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
foreach child in nodeinsert(child,prim)
}// Typically MAXDEPTH=16, MAXPRIMS=2-8
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Median-Cut
Build hierarchy bottom-upChose direction and position carefullySurface-area heuristic
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Surface Area and RaysNumber of rays in a given direction that hit an
object is proportional to its projected area
The total number of rays hitting an object is
Crofton’s theorem:For a convex body:
Example: Sphere
projA
4 A
4
SA
2 24 S r A r
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Surface Area and RaysProbability of a ray hitting an object that
is completely inside a cell is:
cS
oS
Pr o
c
Sr O
S
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Ray Traversal AlgorithmsRecursive inorder traversal
Kaplan, Arvo, Jansen
mint
maxt*t
*maxt t
Intersect(L,tmin,tmax)
mint
maxt
*t
*min maxt t t
Intersect(L,tmin,t*)Intersect(R,t*,tmax)
maxt
mint*t*
mint tIntersect(R,tmin,tmax)
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Hierarchical GridsGood compromise preferred by many
practitioners
IMAGE
IMAGE
IMAGE
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Hierarchical Bounding VolumesCreate tree of bounding volumesChildren are contained within parentCreation preprocess
From model hierarchy Automatic clustering
Searchintersect(node,ray,hits) {
if( intersectp(node->bound,ray)if( leaf(node) )
intersect(node->prims,ray,hits)
elsefor each child
intersect(child,ray,hits)}
Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff
Comparison
Scheme Spheres
Rings
Tree
Uniform grid D=1 244 129 1517
D=20
38 83 781
Hierarchical grid
34 116 34Vlastimil Havran, Best Efficiency Scheme Projecthttp://sgi.felk.cvut.cz/BES/
top related