π± π, πβ² = π(π, πβ²) π π, πβ² +
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
INFOMAGR β Advanced Graphics
Jacco Bikker - November 2016 - February 2017
Lecture 3 - The Perfect BVH Welcome! , = (, ) , - - PowerPoint PPT Presentation
INFOMAGR Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 3 - The Perfect BVH Welcome! , = (, ) , + , , ,
π± π, πβ² = π(π, πβ²) π π, πβ² +
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
Jacco Bikker - November 2016 - February 2017
Advanced Graphics β The Perfect BVH 3
Advanced Graphics β The Perfect BVH 4
Advanced Graphics β The Perfect BVH 5
What Are We Trying To Solve?
A BVH is used to reduce the number of ray/primitive intersections. But: it introduces new intersections. The ideal BVH minimizes:
Advanced Graphics β The Perfect BVH 6
Advanced Graphics β The Perfect BVH 7
BVH versus kD-tree
The BVH better encapsulates geometry. ο¨ This reduces the chance of a ray hitting a node. ο¨ This is all about probabilities! What is the probability of a ray hitting a random triangle? What is the probability of a ray hitting a random node? This probability is proportional to surf rface area area.
Advanced Graphics β The Perfect BVH 8
Optimal Split Plane Position
The ideal split minimizes the cost of a ray intersecting the resulting nodes. This cost depends on:
intersected
The cost of a split is thus: π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’
Advanced Graphics β The Perfect BVH 9
Optimal Split Plane Position
The ideal split minimizes the cost of a ray intersecting the resulting nodes. This cost depends on:
intersected
The cost of a split is thus: π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’
Advanced Graphics β The Perfect BVH 10
Optimal Split Plane Position
Or, more concisely: π΅ππππ’ β π΅ππππ’
1
β πππππ’
1
+ π΅π ππβπ’
1
β ππ ππβπ’
1
+ π΅π ππβπ’ β π΅ππππ’
2
β πππππ’
2
+ π΅π ππβπ’
2
β ππ ππβπ’
2
Advanced Graphics β The Perfect BVH 11
Optimal Split Plane Position
Which positions do we consider? Object subdivision may happen over x, y or z axis. The cost function is constant between primitive centroids. ο¨ For N primitives: 3(π β 1) possible locations ο¨ For a 2-level tree: (3(π β 1))2 configurations
Advanced Graphics β The Perfect BVH 12
SAH and Termination
A split is βnot worth itβ if it doesnβt yield a cost lower than the cost of the parent node, i.e.: π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’ β₯ π΅ β π This provides us with a natural and
(and it solves the problem
Advanced Graphics β The Perfect BVH 13
Optimal Split Plane Position
Evaluating (3(π β 1))2 configurations? Solution: apply the surface area heuristic (SAH) lazily*.
*: Heuristics for Ray Tracing using Space Subdivision, MacDonald & Booth, 1990.
Advanced Graphics β The Perfect BVH 14
Optimal Split Plane Position
Comparing naΓ―ve versus SAH:
SAH & kD-trees:
Advanced Graphics β The Perfect BVH 15
Median Split
Advanced Graphics β The Perfect BVH 16
Surface Area Heuristic
Advanced Graphics β The Perfect BVH 17
Advanced Graphics β The Perfect BVH 18
Advanced Graphics β The Perfect BVH 19
Advanced Graphics β The Perfect BVH 21
Problematic Large Polygons
Large polygons lead to poor BVHs. (far more common than youβd think)
Advanced Graphics β The Perfect BVH 22
Problematic Large Polygons
Large polygons lead to poor BVHs. Using the spatial splits in kD-trees, this is far less of an issue: The triangle will simply be assigned to each subspace.
Advanced Graphics β The Perfect BVH 23
Problematic Large Polygons
Large polygons lead to poor BVHs. Using the spatial splits in kD-trees, this is far less of an issue: The triangle will simply be assigned to each subspace. Solution 1: split large polygons*. Observations:
entire polygon.
*: Early Split Clipping for Bounding Volume Hierarchies, Ernst & Greiner, 2007
Advanced Graphics β The Perfect BVH 24
Early Split Clipping
Observations:
entire polygon.
boxes. Algorithm: Prior to BVH construction, we recursively subdivide any polygon with a surface area that exceeds a certain threshold.
Issues:
regardless of surrounding geometry
in the same leaf
(some of these issues are resolved in: The Edge Volume Heuristic - Robust Triangle Subdivision for Improved BVH Performance, Dammertz & Keller, 2008)
Advanced Graphics β The Perfect BVH 25
Spatial Splits for BVHs
Observation: spatial splits are not limited to kD-trees. But: spatial splits tend to increase the cost of a split. Idea:
*: Spatial Splits in Bounding Volume Hierarchies, Stich et al., 2009
π·π‘ππππ’ = π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’ < π΅ β π
Advanced Graphics β The Perfect BVH 26
State of the Art: SBVH
Summary: high quality bounding volume hierarchies can be
Compared to a regular SAH BVH, spatial splits improve the BVH by ~25% (see paper for scenes and figures).
Advanced Graphics β The Perfect BVH 27
Advanced Graphics β The Perfect BVH 28
Advanced Graphics β The Perfect BVH 30
Summary of BVH Characteristics
A BVH provides significant freedom compared to e.g. a kD-tree:
Some consequences / opportunities:
Advanced Graphics β The Perfect BVH 31
Refitting
Q: What happens to the BVH of a tree model, if we make it bend in the wind? A: Likely, only bounds will change; the topology of the BVH will be the same (or at least similar) in each frame. Refitting: Updating the bounding boxes stored in a BVH to match changed primitive coordinates.
Advanced Graphics β The Perfect BVH 32
Refitting
Updating the bounding boxes stored in a BVH to match changed primitive coordinates. Algorithm:
Advanced Graphics β The Perfect BVH 33
Refitting - Suitability
Advanced Graphics β The Perfect BVH 34
Refitting β Practical
Order of nodes in the node array: We will never find the parent of node X at a position greater than X. Therefore:
for( int i = N-1; i >= 0; i-- ) nodeArray[i].AdjustBounds();
N-1 BVH node array Root node Level 1
Advanced Graphics β The Perfect BVH 36
Rapid BVH Construction
Refitting allows us to update hundreds of thousands of primitives in real-
Rebuilding a BVH requires 3πππππ split plane evaluations. Options:
Advanced Graphics β The Perfect BVH 37
Advanced Graphics β The Perfect BVH 38
Binned BVH Construction* Binned construction: Evaluate SAH at N discrete intervals.
*: On fast Construction of SAH-based Bounding Volume Hierarchies, Wald, 2007
Advanced Graphics β The Perfect BVH 39
Binned BVH Construction
Detailed algorithm: 1. Calculate spatial bounds 2. Calculate object centroid bounds 3. Calculate intervals (efficiently and accurately!) 4. Populate bins 5. Sweep: evaluate cost, keep track of counts 6. Use best position
Advanced Graphics β The Perfect BVH 40
Binned BVH Construction
Performance evaluation: 1.9s for 10M triangles (8 cores @ 2.6Ghz).
Advanced Graphics β The Perfect BVH 41
Jacco Bikker - November 2016 - February 2017
next lecture: βReal-time Ray Tracingβ