Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration."— Presentation transcript:

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

2 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff 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

3 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Uniform Grids Preprocess scene 1.Find bounding box

4 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Uniform Grids Preprocess scene 1.Find bounding box 2.Determine grid resolution

5 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Uniform Grids Preprocess scene 1.Find bounding box 2.Determine grid resolution 3.Place object in cell if its bounding box overlaps the cell

6 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Uniform Grids Preprocess scene 1.Find bounding box 2.Determine grid resolution 3.Place object in cell if its bounding box overlaps the cell 4.Check that object overlaps cell (expensive!)

7 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Uniform Grids Preprocess scene Traverse grid 3D line = 3D-DDA 6-connected line

8 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Caveat: Overlap Optimize objects that overlap multiple cells Caveat 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

9 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

10 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Spatial Hierarchies A B C D A B C D Point location by recursive search

11 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Variations KD tree octtreeBSP tree

12 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff 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 foreach child in node insert(child,prim) } // Typically MAXDEPTH=16, MAXPRIMS=2-8

13 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Median-Cut Build hierarchy bottom-up Chose direction and position carefully Surface-area heuristic

14 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Surface Area and Rays Number 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

15 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Surface Area and Rays Probability of a ray hitting an object that is completely inside a cell is:

16 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff 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)

17 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Hierarchical Grids Good compromise preferred by many practitioners IMAGE

18 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff 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) }

19 Greg Humphreys, Spring 2003Intro Graphics Raytracing Stuff Comparison SchemeSpheresRingsTree Uniform gridD=12441291517 D=203883781 Hierarchical grid3411634 Vlastimil Havran, Best Efficiency Scheme Project http://sgi.felk.cvut.cz/BES/


Download ppt "CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration."

Similar presentations


Ads by Google