1 / 39

Advanced Computer Graphics Lecture 4: Faster Ray Tracing

Advanced Computer Graphics Lecture 4: Faster Ray Tracing. David Luebke cs551dl@cs.virginia.edu http://www.cs.virginia.edu/~cs551dl. Administrivia. Read Chapter 9 Verify collection of Exercise 1. Recap. Ray tracing is too slow Chapter 9: Different methods to speed it up

khoi
Download Presentation

Advanced Computer Graphics Lecture 4: Faster Ray Tracing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Computer GraphicsLecture 4: Faster Ray Tracing David Luebke cs551dl@cs.virginia.edu http://www.cs.virginia.edu/~cs551dl David Luebke 9/17/2014

  2. Administrivia • Read Chapter 9 • Verify collection of Exercise 1 David Luebke 9/17/2014

  3. Recap • Ray tracing is too slow • Chapter 9: • Different methods to speed it up • Ways of using ray tracing selectively David Luebke 9/17/2014

  4. Recap • Speedup Techniques • Intersect rays faster • Shoot fewer rays • Shoot “smarter” rays David Luebke 9/17/2014

  5. Recap • Intersect Rays Faster • Bounding volumes • Spatial partitions • Reordering ray intersection tests • Optimizing intersection tests David Luebke 9/17/2014

  6. 7 5 3 1 8 6 0 9 2 4 Recap • Bounding volumes • Idea: before intersecting a ray with a collection of objects, test it against one simple object that bounds the collection 7 5 3 1 8 6 0 9 2 4 David Luebke 9/17/2014

  7. Recap • Hierarchical bounding volumes • Group nearby volumes hierarchically • Test rays against hierarchy top-down David Luebke 9/17/2014

  8. Bounding Volumes • Some different bounding volumes: • Spheres • Axis-aligned bounding boxes (AABBs) • Oriented bounding boxes (OBBs) • Slabs • Show examples David Luebke 9/17/2014

  9. Bounding Volumes • What makes a “good” bounding volume? • Tightness of fit (expressed how?) • Simplicity of intersection Total cost = b*B + i*I • b: # times volume tested for intersection • B: cost of ray-volume intersection test • i: # times item is tested for intersection • I: cost of ray-item intersection test David Luebke 9/17/2014

  10. Bounding Volumes • Spheres • Cheap intersection test • Poor fit • A pain to fit to data David Luebke 9/17/2014

  11. Bounding Volumes • Axis-aligned bounding boxes (AABBs) • Relatively cheap intersection test • Usually better fit • Trivial to fit to data David Luebke 9/17/2014

  12. Bounding Volumes • Oriented bounding boxes (OBBs) • Medium-expensive intersection test • Very good fit (asymptotically better) • Medium-difficult to fit to data David Luebke 9/17/2014

  13. Intermission:Parallel Close Proximity We will analyze how OBBs, AABBs, and spheres should perform in parallel close proximity situations. • Define parallel close proximity • Convergence rates of BV types • Asymptotic performance • Experimental evidence (graph) (The following 11 slides are courtesy Stefan Gottschalk, UNC) David Luebke 9/17/2014

  14. Parallel Close Proximity Two models are in parallel close proximity when every point on each model is a given fixed distance (e) from the other model. Q: How does the number of BV tests increase as the gap size decreases? David Luebke 9/17/2014

  15. 1 Parallel Close Proximity:Convergence David Luebke 9/17/2014

  16. 1 1 / 2 2 / 4 Parallel Close Proximity:Convergence David Luebke 9/17/2014

  17. Parallel Close Proximity:Convergence 1 David Luebke 9/17/2014

  18. 1 / 1 4 / 2 2 Parallel Close Proximity:Convergence David Luebke 9/17/2014

  19. Parallel Close Proximity:Convergence 1 David Luebke 9/17/2014

  20. 1 1 / / 16 4 Parallel Close Proximity:Convergence David Luebke 9/17/2014

  21. 1 1 / / 4 4 1 / 4 Parallel Close Proximity:Convergence David Luebke 9/17/2014

  22. k 2k O(n) 2 O(n ) Spheres & AABBs OBBs Parallel Close Proximity:Asymptotic Performance David Luebke 9/17/2014

  23. Parallel Close Proximity: Experiment OBBs asymptotically outperform AABBs and spheres Log-log plot Number of BV tests Gap Size (e) David Luebke 9/17/2014

  24. Bounding Volumes • Slabs (parallel planes) • Comparatively expensive • Very good fit • A pain to fit to data David Luebke 9/17/2014

  25. Bounding Volume Hierarchies • What makes a “good” bounding volume hierarchy? • Grouped objects (or volumes) should be near each other • Volume should be minimal • Sum of all volumes should be minimal • Top of the tree is most critical • Constructing the hierarchy should pay for itself! David Luebke 9/17/2014

  26. Spatial Partitioning • Hierarchical bounding volumes surround objects in the scene with (possibly overlapping) volumes • Often tightest fit • Spatialpartitioning techniques classify all space into non-overlapping portions • Easier to generate automatically • Can “walk” ray from partition to partition David Luebke 9/17/2014

  27. Spatial Partitioning • Some spatial partitioning schemes: • Uniform grid (2-D or 3-D) • Octree • k-D tree • BSP-tree • Show examples David Luebke 9/17/2014

  28. Uniform Grid • Uniform grid pros: • Very simple and fast to generate • Very simple and fast to trace rays across (How?) • Uniform grid cons: • Not adaptive • Wastes storage on empty space • Assumes uniform spread of data David Luebke 9/17/2014

  29. Octree • Octree pros: • Simple to generate • Adaptive • Octree cons: • Less easy to trace rays across (How?) • Adaptive only in scale David Luebke 9/17/2014

  30. k-D Trees • k-D tree pros: • Moderately simple to generate • More adaptive than octrees • k-D tree cons: • Less efficient to trace rays across • Moderately complex data structure David Luebke 9/17/2014

  31. BSP Trees • BSP tree pros: • Extremely adaptive • Simple & elegant data structure • BSP tree cons: • Very hard to create optimum BSP • Splitting planes can explode storage • Simple but slow to trace rays across David Luebke 9/17/2014

  32. Ray Space Subdivision • Weird acceleration scheme award… • Octree, BSP Tree, grids: 3-D subdivision schemes • Arvo & Kirk: 5-D subdivision scheme • Position: x, y, z • Direction: u, v • Draw it… David Luebke 9/17/2014

  33. Reordering RayIntersection Tests • Caching ray hits • Memory-coherent ray tracing David Luebke 9/17/2014

  34. Caching Ray Hits • Record what object the “last ray” hit • Start by checking that object • Especially for shadow rays…(why?) • RSRT uses a multi-level shadow cache(what’s that?) David Luebke 9/17/2014

  35. Memory-Coherent Ray Tracing • Goal: ray trace very large scenes • Problem: ray tracing typically exhibits poor memory coherence (Why?) • Solution: re-order ray computations • Ray trace where geometry in cache • Postpone rays going out-of-core David Luebke 9/17/2014

  36. Optimizing Ray Intersection Tests • Fine-tune the math! • Share subexpressions • Precompute everything possible • Code with care • Even use assembly, if necessary • Will get its own lecture David Luebke 9/17/2014

  37. Speedup Techniques • Speedup Techniques • Intersect rays faster • Shoot fewer rays • Shoot “smarter” rays David Luebke 9/17/2014

  38. Shoot Fewer Rays • Adaptive depth control • Naïve ray tracer: spawn 2 rays per intersection until max recursion limit • In practice, few surfaces are transparent or reflective • Contribution of most rays to image: 0% • Don’t shoot rays w/ contribution near 0% David Luebke 9/17/2014

  39. Shoot Fewer Rays • Adaptive sampling • Shoot rays coarsely, interpolating their values across pixels • Where adjacent rays differ greatly in value, sample more finely • Stop when some maximum resolution is reached • Show example David Luebke 9/17/2014

More Related