ray tracing 2: acceleration

19
CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration

Upload: chaim

Post on 19-Jan-2016

40 views

Category:

Documents


1 download

DESCRIPTION

Ray Tracing 2: Acceleration. 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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Ray Tracing 2: Acceleration

CS 445Greg Humphreys, Spring 2003

Ray Tracing 2:Acceleration

Page 2: 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

Page 3: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Uniform GridsPreprocess scene1. Find bounding box

Page 4: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Uniform GridsPreprocess scene1. Find bounding box2. Determine grid

resolution3 | |n d O

Page 5: Ray Tracing 2: Acceleration

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

Page 6: Ray Tracing 2: Acceleration

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

Page 7: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Uniform GridsPreprocess sceneTraverse grid

3D line = 3D-DDA6-connected line

Page 8: Ray Tracing 2: Acceleration

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

Page 9: Ray Tracing 2: Acceleration

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

Page 10: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Spatial Hierarchies

A

B C

D

A

B

C

D

Point location by recursive search

Page 11: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Variations

KD tree octtree BSP tree

Page 12: Ray Tracing 2: Acceleration

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

Page 13: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Median-Cut

Build hierarchy bottom-upChose direction and position carefullySurface-area heuristic

Page 14: Ray Tracing 2: Acceleration

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

Page 15: Ray Tracing 2: Acceleration

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

Page 16: Ray Tracing 2: Acceleration

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)

Page 17: Ray Tracing 2: Acceleration

Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff

Hierarchical GridsGood compromise preferred by many

practitioners

IMAGE

IMAGE

IMAGE

Page 18: Ray Tracing 2: Acceleration

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)}

Page 19: Ray Tracing 2: Acceleration

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/