Download presentation
Presentation is loading. Please wait.
Published byAvice Flynn Modified over 8 years ago
1
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke cs551dl@cs.virginia.eduhttp://www.cs.virginia.edu/~cs551dl
2
David Luebke 3/5/2016 Administrivia l Read Chapter 9 l Verify collection of Exercise 1
3
David Luebke 3/5/2016 Recap l Ray tracing is too slow l Chapter 9: –Different methods to speed it up –Ways of using ray tracing selectively
4
David Luebke 3/5/2016 Recap l Speedup Techniques –Intersect rays faster –Shoot fewer rays –Shoot “smarter” rays
5
David Luebke 3/5/2016 Recap l Intersect Rays Faster –Bounding volumes –Spatial partitions –Reordering ray intersection tests –Optimizing intersection tests
6
David Luebke 3/5/2016 Recap l Bounding volumes –Idea: before intersecting a ray with a collection of objects, test it against one simple object that bounds the collection 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
7
David Luebke 3/5/2016 Recap l Hierarchical bounding volumes –Group nearby volumes hierarchically –Test rays against hierarchy top-down
8
David Luebke 3/5/2016 Bounding Volumes l Some different bounding volumes: –Spheres –Axis-aligned bounding boxes (AABBs) –Oriented bounding boxes (OBBs) –Slabs l Show examples
9
David Luebke 3/5/2016 Bounding Volumes l 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 : # times volume tested for intersection B : cost of ray-volume intersection test B : cost of ray-volume intersection test i : # times item is tested for intersection i : # times item is tested for intersection I : cost of ray-item intersection test I : cost of ray-item intersection test
10
David Luebke 3/5/2016 Bounding Volumes l Spheres –Cheap intersection test –Poor fit –A pain to fit to data
11
David Luebke 3/5/2016 Bounding Volumes l Axis-aligned bounding boxes (AABBs) –Relatively cheap intersection test –Usually better fit –Trivial to fit to data
12
David Luebke 3/5/2016 Bounding Volumes l Oriented bounding boxes (OBBs) –Medium-expensive intersection test –Very good fit (asymptotically better) –Medium-difficult to fit to data
13
David Luebke 3/5/2016 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)
14
David Luebke 3/5/2016 Parallel Close Proximity Q: How does the number of BV tests increase as the gap size decreases? Two models are in parallel close proximity when every point on each model is a given fixed distance ( ) from the other model.
15
David Luebke 3/5/2016 Parallel Close Proximity: Convergence 1
16
David Luebke 3/5/2016 1 2 / 2 1 4 / Parallel Close Proximity: Convergence
17
David Luebke 3/5/2016 1 Parallel Close Proximity: Convergence
18
David Luebke 3/5/2016 1 2 / 2 1 4 / Parallel Close Proximity: Convergence
19
David Luebke 3/5/2016 1 Parallel Close Proximity: Convergence
20
David Luebke 3/5/2016 1 4 / 1 16 / Parallel Close Proximity: Convergence
21
David Luebke 3/5/2016 1 4 / 1 4 / 1 4 / Parallel Close Proximity: Convergence
22
David Luebke 3/5/2016 OBBs k O(n) Spheres & AABBs 2k O(n ) 2 Parallel Close Proximity: Asymptotic Performance
23
David Luebke 3/5/2016 OBBs asymptotically outperform AABBs and spheres Log-log plot Gap Size ( ) Number of BV tests Parallel Close Proximity: Experiment
24
David Luebke 3/5/2016 Bounding Volumes l Slabs (parallel planes) –Comparatively expensive –Very good fit –A pain to fit to data
25
David Luebke 3/5/2016 Bounding Volume Hierarchies l 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!
26
David Luebke 3/5/2016 Spatial Partitioning l Hierarchical bounding volumes surround objects in the scene with (possibly overlapping) volumes –Often tightest fit l Spatial partitioning techniques classify all space into non-overlapping portions –Easier to generate automatically –Can “walk” ray from partition to partition
27
David Luebke 3/5/2016 Spatial Partitioning l Some spatial partitioning schemes: –Uniform grid (2-D or 3-D) –Octree –k-D tree –BSP-tree l Show examples
28
David Luebke 3/5/2016 Uniform Grid l Uniform grid pros: –Very simple and fast to generate –Very simple and fast to trace rays across (How?) l Uniform grid cons: –Not adaptive n Wastes storage on empty space n Assumes uniform spread of data
29
David Luebke 3/5/2016 Octree l Octree pros: –Simple to generate –Adaptive l Octree cons: –Less easy to trace rays across (How?) –Adaptive only in scale
30
David Luebke 3/5/2016 k-D Trees l k-D tree pros: –Moderately simple to generate –More adaptive than octrees l k-D tree cons: –Less efficient to trace rays across –Moderately complex data structure
31
David Luebke 3/5/2016 BSP Trees l BSP tree pros: –Extremely adaptive –Simple & elegant data structure l BSP tree cons: –Very hard to create optimum BSP –Splitting planes can explode storage –Simple but slow to trace rays across
32
David Luebke 3/5/2016 Ray Space Subdivision l Weird acceleration scheme award… l Octree, BSP Tree, grids: 3-D subdivision schemes l Arvo & Kirk: 5-D subdivision scheme –Position: x, y, z –Direction: u, v l Draw it…
33
David Luebke 3/5/2016 Reordering Ray Intersection Tests l Caching ray hits l Memory-coherent ray tracing
34
David Luebke 3/5/2016 Caching Ray Hits l Record what object the “last ray” hit l Start by checking that object l Especially for shadow rays…(why?) l RSRT uses a multi-level shadow cache (what’s that?)
35
David Luebke 3/5/2016 Memory-Coherent Ray Tracing l Goal: ray trace very large scenes l Problem: ray tracing typically exhibits poor memory coherence (Why?) l Solution: re-order ray computations –Ray trace where geometry in cache –Postpone rays going out-of-core
36
David Luebke 3/5/2016 Optimizing Ray Intersection Tests l Fine-tune the math! –Share subexpressions –Precompute everything possible l Code with care –Even use assembly, if necessary –Will get its own lecture
37
David Luebke 3/5/2016 Speedup Techniques l Speedup Techniques –Intersect rays faster –Shoot fewer rays –Shoot “smarter” rays
38
David Luebke 3/5/2016 Shoot Fewer Rays l Adaptive depth control –Naïve ray tracer: spawn 2 rays per intersection until max recursion limit –In practice, few surfaces are transparent or reflective n Contribution of most rays to image: 0% n Don’t shoot rays w/ contribution near 0%
39
David Luebke 3/5/2016 Shoot Fewer Rays l 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 l Show example
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.