Ray Tracing Dynamic Scenes Using BVHs
Transcript of Ray Tracing Dynamic Scenes Using BVHs
![Page 1: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/1.jpg)
![Page 2: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/2.jpg)
Ray Tracing Dynamic Scenes Using BVHs
Dinesh Manocha, Christian LauterbachUniversity of North Carolina at Chapel Hill http://gamma.cs.unc.edu/RT
![Page 3: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/3.jpg)
Dynamic Scenes
• Animated characters: cloth and hair animation
• Deformable models
• Explosions and breaking objects: non-rigid motion
![Page 4: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/4.jpg)
Dynamic Scenes: Interactive Ray Tracing
• Computer games
• Interactive walkthroughs and design reviews
• Computer-generated movies
• Medical applications
![Page 5: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/5.jpg)
Dynamic Scenes: Interactive Ray Tracing
• Computer games
• Interactive walkthroughs and design reviews
• Medical applications
Most prior work on interactive ray tracing is limited to static scenes
![Page 6: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/6.jpg)
Overview
• Ray tracing dynamic scenes
• Ray tracing using bounding volume hierarchies
• Other approaches
![Page 7: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/7.jpg)
Ray Tracing Dynamic Scenes
• General problem: kd-tree based ray tracing is fast for static models, but many interactive applications use dynamic scenes
![Page 8: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/8.jpg)
Ray Tracing Dynamic Scenes
• Solution 1: Rebuild kd-tree each frame– Rebuild kd-tree in a lazy manner, approximate SAH
(see talk by Bill Mark and Gordon later)
![Page 9: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/9.jpg)
Ray Tracing Dynamic Scenes
• Solution 1: Rebuild kd-tree each frame– Rebuild kd-tree in a lazy manner, approximate SAH
(see talk by Bill Mark and Gordon later)
– Move objects bounding boxes around and transform rays (for hierarchical update) [Wald et al. 03]
![Page 10: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/10.jpg)
Ray Tracing Dynamic Scenes
• Solution 1: Rebuild kd-tree each frame– Rebuild kd-tree in a lazy manner, approximate SAH
(see talk by Bill Mark and Gordon later)
– Can just move objects bounding boxes around and transform rays (for hierarchical movement) [Wald et al. 03]
– Motion decomposition, fuzzy kd-trees [Günther et al. 06]
![Page 11: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/11.jpg)
Ray Tracing Dynamic Scenes
• Solution 1: Rebuild kd-tree each frame– Rebuild kd-tree in a lazy manner, approximate SAH
(see talk by Bill Mark and Gordon later)
– Can just move objects bounding boxes around and transform rays (for hierarchical movement) [Wald et al. 03]
– Motion decomposition, fuzzy kd-trees [Günther et al. 06]
• Solution 2: use different hierarchical structure
![Page 12: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/12.jpg)
Hierarchical Representations for Dynamic Ray Tracing
• Lots of developments in the last year:– Grids [Wald et al. 06a] (see talk after this)
– Spatial kd-trees / b-kd-trees [Wächter and Keller 06,Woop et al. 06, Havran et al. 06]
– Bounding volume hierarchies[Wald et al. 06b, Boulos et al. 06, Lauterbach et al. 06]
![Page 13: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/13.jpg)
Hierarchical Representations for Dynamic Ray Tracing
• Lots of developments the last year:– Grids [Wald et al. 06a] (see talk after this)
– Spatial kd-trees / b-kd-trees [Wächter and Keller 06,Woop et al. 06, Havran et al. 06]
– Bounding volume hierarchies (BVHs)[Wald et al. 06b, Boulos et al. 06, Lauterbach et al. 06]
![Page 14: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/14.jpg)
Bounding Volume Hierarchies: BVHs
• Tree of bounding volumes(sphere, AABB, OBB, k-DOP,spherical shells, etc.)
• Each bounding volume encloses “nearby” primitives• Parent node primitives are union of children node
primitives
![Page 15: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/15.jpg)
Spatial partitioning vs. Object Hierarchies
• Spatial partitioning: – space is subdivided into disjoint regions
(e.g. grid, kd-tree, octree, ...)
![Page 16: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/16.jpg)
Spatial partitioning vs. Object Hierarchies
• Spatial partitioning: – space is subdivided into disjoint regions
(e.g. grid, kd-tree, octree, ...)
• Object hierarchy: – groups or clusters of objects/primitives are
subdivided (BVH, s-kd-tree)
![Page 17: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/17.jpg)
Spatial partitioning vs. BVH Hierarchies
• Implications for ray tracing– Spatial partitioning: Objects referenced in
multiple nodes (overlap in object space)
– BVH Hierarchies: Nodes can overlap each other (overlap in 3D space)
• Spatial partitioning allows easier front-to-back ordering
![Page 18: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/18.jpg)
BVHs for Ray Tracing
• One of the first acceleration structures used for Ray Tracing [Rubin and Whitted 80, Weghorst et al. 84]
• Efficient AABB intersection available– Using slabs [Smits 98]
– Using Plücker coordinates [Mahovsky and Wyvill 04]
• First interactive versions presented in [Wald et al. 06], [Boulos et al. 06], [Lauterbach et al. 06]
![Page 19: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/19.jpg)
BVHs for intersection tests
• Widely used for intersection computations– Ray tracing
– Visibility culling: view frustum and occlusion culling
– Collision and proximity computations
– Other applications
![Page 20: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/20.jpg)
Collision Queries using BVHs
• BVHs widely used for collision and distance queries
• Rigid models: – OBBs work well for collision queries (RAPID package)– Swept spheres of rectangles work well for distance
queries (PQP package)
• Deformable models: AABBs appear to offer good balance between speed and fit [Bergen 97; Larsson et al. 2001; Govindaraju et al. 2005; Sud et al. 2006]
![Page 21: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/21.jpg)
Interactive collision computation
Breaking Objects:
[Sud et al.: SIGGRAPH 2006]
![Page 22: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/22.jpg)
Ray Tracing vs. Collision Queries
• Most collision algorithms perform culling
– Cull away non-overlapping objects
– Compute localized overlapping regions
– No need to compute front-to-back ordering
![Page 23: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/23.jpg)
BVHs for Ray Tracing
• AABBs have many benefits– Simple ray-box intersection test
– Good fit for many scenes/primitives
– Compact storage (we use 32 bytes/node)
– Usually limited to binary tree, 1 tri/leaf
![Page 24: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/24.jpg)
BVH based RT algorithm
• Pretty simple:– Start from root
– If ray intersects AABB, try all children, too:• is inner node: recurse on both children
• is leaf node: intersect with primitive(s)
• Naïve implementation far slower than kd-trees!
![Page 25: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/25.jpg)
Why are BVHs slower?
• Intersection test more costly– Up to 6 ray-plane intersections for AABB (slabs test)
– Just 1 for kd-tree
• No front-to-back ordering– Cannot stop after finding first hit
• Nodes take more space– 32 bytes vs. 8 bytes
![Page 26: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/26.jpg)
On the other hand…
• AABBs can provide tighter fit automatically– No empty leafs, tree does not need to be as deep
– Primitives only referenced once
less nodes in hierarchy
• #nodes known in advance (2n-1)(if 1 primitive/leaf)
![Page 27: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/27.jpg)
Hierarchy updates
• AABBs can provide tighter fit automatically– No empty leafs, tree does not need to be as deep
– Primitives only referenced once
less nodes in hierarchy
• #nodes known in advance (2n-1)(if 1 primitive/leaf)
• Most important: can be updated
![Page 28: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/28.jpg)
Hierarchy updates
• What does updating mean?– Underlying geometry changes
– Update will ensure correctness of hierarchy without rebuilding it
• Should be faster than rebuild
![Page 29: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/29.jpg)
Traversal optimizations
• Ray coherence methods for kd-trees work here, too!
• Use 2x2 ray packets with SIMD instructions– Same principle as for kd-trees
– If any of the rays intersect node, all intersect
– Traversal finishes when all rays finish(keep track of ray status)
• Larger speedup than for kd-trees (2-3x)
• Can use packets with different direction signs (unlike kd-trees)
![Page 30: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/30.jpg)
Traversal optimizations (2)
• Can also use frustum culling– Have efficient SIMD frustum-AABB intersect
[Reshetov et al. 05]
– Can use this for early rejection in packet-box intersection: [Wald06]
• Test first active ray in packet: if it hits, then packet intersects
• Otherwise: intersect frustum with box
– Misses? Then reject
– Hits? Then test all rays in packet
![Page 31: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/31.jpg)
Traversal optimizations (3)
• Fake depth ordering– Store subdivision axis in BVH node
– Intersect with 'near' node first
– Don't intersect nodes farther away than closest hit
• 32-byte nodes help cache efficiency
![Page 32: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/32.jpg)
Dynamic Scenes: updating BVHs
• Post-order traversal of BVH– Update children's AABB, then update own
– At leaf level, update from primitives
– Also update additional information such as axis
• O(n) time– Usually a few ms for small scenes
– May become too long for large models!
![Page 33: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/33.jpg)
Dynamic scenes: BVH degradation
• Quality of BVH may decrease over animation– Update does not change tree topology
– Rebuild may be necessary
– How to detect?
• In worst-case scene:– Performance dropping an order of magnitude over 20
animation frames
– Not as bad for normal scenes, though
![Page 34: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/34.jpg)
Quality degradation
• Use heuristic to detect degradation
• Assume performance lower when BVHs contain lots of empty space:
child 1
child 2child 1
child 2
after build after updates
![Page 35: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/35.jpg)
Rebuild heuristic
• How to measure quality?– Use ratio of surface area parent to children
• SA(parent) / ( SA(child1) + SA(child2) )
• Save on rebuild for each node (4 bytes/node)
– On each update: compare to initial value
– Sum up differences and normalize
– If above threshold: initiate rebuild• ~30-40% work well in practise
![Page 36: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/36.jpg)
Multithreaded update
• Updates take time from rendering
• Want parallel updates for speed– Easy in our case, because trees roughly balanced
– Just assign a subtree of the same level to each thread
– Combine results afterwards
– Works well with current trees
![Page 37: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/37.jpg)
Results (1)
• Interactive performance on scenes of medium complexity shown by[Wald et al. 06, Lauterbach et al. 06]
(from [Lauterbach et al. 06], on Pentium-D 2.8 Ghz at 512x512 with 8x8 ray packets and secondary rays)
![Page 38: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/38.jpg)
Results (2): vs. kd-trees
• Similar memory use
• Build times:– Much faster build for spatial median
– Similar for surface area heuristic (shown below)
![Page 39: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/39.jpg)
Comparison to s-kd-tree
• Spatial kd-trees– Hybrid between kd-tree and BVH, first used for RT
in [Wächter and Keller 06, Havran et al. 06]
– Idea: instead of storing full bounding box, store bounds in subdivison axis (12 bytes/node)
left bound
right bound
![Page 40: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/40.jpg)
Comparison to s-kd-tree (2)
• Construction: similar to BVH
• Traversal: similar to kd-tree
• b-kd-trees:– Similar, just storing left/right bound for both sides
– Used in hardware ray tracer [Woop et al. 06]
![Page 41: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/41.jpg)
Results: BVH vs. s-kd-trees
• Compared to BVHs– Slightly faster rendering
– less memory (if not saving empty leafs)
– But: • More unpredictable number of nodes
• Very fast degradation when updated
• More complicated packet traversal
![Page 42: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/42.jpg)
Results(5) – Videos / Demo
Cloth simulation, 40k triangles, 210 keyframes
![Page 43: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/43.jpg)
Results(5) – Videos / Demo
Bunny deformation, 69k triangles
![Page 44: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/44.jpg)
Results(5) – Videos / Demo
Animation from BART museum benchmark [Lext et al. 01], 16k triangles
![Page 45: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/45.jpg)
Results(5) – Videos / Demo
Same as before, showing frames where hierarchy was rebuilt
![Page 46: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/46.jpg)
Future work
• How to handle larger models?– Good multithreaded update/rebuild
– Partial/hybrid updates• Want to avoid full rebuild (stops interactivity)
– Current rebuild heuristic not perfect
![Page 47: Ray Tracing Dynamic Scenes Using BVHs](https://reader035.fdocuments.net/reader035/viewer/2022071602/613d77bc736caf36b75daddc/html5/thumbnails/47.jpg)
References[Boulos et al. 06]: Solomon Boulos, Dave Edwards, J Dylan Lacewell, Joe Kniss, Jan Kautz, Peter Shirley, and Ingo Wald. Interactive Distribution Ray Tracing. Technical Report, SCI Institute, University of Utah, No UUSCI-2006-022, 2006. [Günther et al. 06]:Johannes Günther, Heiko Friedrich, Ingo Wald, Hans-Peter Seidel, and Philipp Slusallek. Ray tracing animated scenes using motion decomposition. Computer Graphics Forum, 25(3), September 2006 (to appear)[Havran et al. 06]: Vlastimil Havran, Robert Herzog, and Hans-Peter Seidel. On Fast Construction of Spatial Hierarchies for Ray Tracing. Submitted to RT’06, 2006.[Lauterbach et al. 06]: Christian Lauterbach, Sung-Eui Yoon, David Tuft, Dinesh Manocha. RT-DEFORM: Interactive Ray Tracing of Dynamic Scenes using BVHs. Technical Report TR06-10, University of North Carolina at Chapel Hill, 2006.[Mahovsky and Wyvill 04]: Jeffrey Mahovsky, Brian Wyvill. Fast Ray-axis Aligned Bounding Box Overlap Tests with Plücker Coordinates. Journal of Graphics Tools, 9(1):35-46, 2004 [Reshetov et al. 05]: Alexander Reshetov, Alexei Soupikov, and Jim Hurley. Multi-level ray tracing algorithm. ACM Trans. Graph., 24(3):1176–1185, 2005.[Rubin and Whitted 80]: Steven M. Rubin and Turner Whitted. A 3-dimensional representation for fast rendering of complex scenes. Computer Graphics, 14(3):110–116, July 1980.[Smits98]: Brian Smits. Efficiency issues for ray tracing. Journal of Graphics Tools: JGT, 3(2):1–14, 1998.[Wächter and Keller 06]: Carsten Wächter and Andreas Keller. Instant Ray Tracing: The Bounding Interval Hierarchy. Rendering Techniques 2006: Eurographics Symposium on Rendering, 2006.[Wald et al. 03]: Ingo Wald, Carsten Benthin, and Philipp Slusallek. Distributed Interactive Ray Tracing of Dynamic Scenes. In Proceedings of the IEEE Symposium on Parallel and Large-Data Visualization and Graphics (PVG), 2003.[Wald et al. 06a]:Ingo Wald, Thiago Ize, Andrew Kensler, Aaron Knoll, and Steven Parker. Ray Tracing Animated Scenes using Coherent Grid Traversal. In ACM Transaction on Graphics (Proc. SIGGRAPH 2006).[Wald et al. 06b]: Ingo Wald, Solomon Boulos, and Peter Shirley. Ray Tracing Deformable Scenes using Dynamic Bounding Volume Hierarchies. Technical Report, SCI Institute, University of Utah, No UUSCI-2005-014 (conditionally accepted at ACM Transactions on Graphics), 2006.[Woop et al. 06]: Sven Woop, Gerd Marmitt, and Philipp Slusallek. B-KD Trees for Hardware Accelerated Ray Tracing of Dynamic Scenes. In Proceedings of Graphics Hardware (to appear), 2006.