π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
INFOMAGR β Advanced Graphics
Jacco Bikker - November 2018 - February 2019
Lecture 3 - The Perfect BVH Welcome! , = (, ) , - - PowerPoint PPT Presentation
INFOMAGR Advanced Graphics Jacco Bikker - November 2018 - February 2019 Lecture 3 - The Perfect BVH Welcome! , = (, ) , + , , ,
π± π, πβ² = π(π, πβ²) π π, πβ² + ΰΆ±
π»
π π, πβ², πβ²β² π± πβ², πβ²β² ππβ²β²
Jacco Bikker - November 2018 - February 2019
βͺ Building Better BVHs βͺ The Problem of Large Polygons βͺ Refitting βͺ Fast BVH Construction
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: βͺ # of ray / primitive intersections βͺ # of ray / node intersections.
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 surface ar area.
Advanced Graphics β The Perfect BVH 8
Route 1: 10% up-time, $1000 fine Route 2: 100% up-time, $100 fine
Advanced Graphics β The Perfect BVH 9
Optimal Split Plane Position
The ideal split minimizes the expected cost of a ray intersecting the resulting nodes. This expected cost is based on: βͺ Number of primitives that will have to be intersected βͺ Probability of this happening The cost of a split is thus: π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’
Advanced Graphics β The Perfect BVH 10
Optimal Split Plane Position
The ideal split minimizes the cost of a ray intersecting the resulting nodes. This cost depends on: βͺ Number of primitives that will have to be intersected βͺ Probability of this happening The cost of a split is thus: π΅ππππ’ β πππππ’ + π΅π ππβπ’ β ππ ππβπ’
Advanced Graphics β The Perfect BVH 11
Optimal Split Plane Position
Or, more concisely: π΅ππππ’ β π΅ππππ’
1
β πππππ’
1
+ π΅π ππβπ’
1
β ππ ππβπ’
1
+ π΅π ππβπ’ β π΅ππππ’
2
β πππππ’
2
+ π΅π ππβπ’
2
β ππ ππβπ’
2
Advanced Graphics β The Perfect BVH 12
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 13
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 14
Optimal Split Plane Position
Evaluating (3(π β 1))2 configurations? Solution: apply the surface area heuristic (SAH) in a greedy manner*.
*: Heuristics for Ray Tracing using Space Subdivision, MacDonald & Booth, 1990.
Advanced Graphics β The Perfect BVH 15
Optimal Split Plane Position
Comparing naΓ―ve versus SAH: βͺ SAH will cut #intersections in half; βͺ expect ~2x better performance. SAH & kD-trees: βͺ Same scheme applies.
Advanced Graphics β The Perfect BVH 16
Median Split
Advanced Graphics β The Perfect BVH 17
Surface Area Heuristic
Advanced Graphics β The Perfect BVH 18
Advanced Graphics β The Perfect BVH 19
Advanced Graphics β The Perfect BVH 20
βͺ Building Better BVHs βͺ The Problem of Large Polygons βͺ Refitting βͺ Fast BVH Construction
Advanced Graphics β The Perfect BVH 22
Problematic Large Polygons
Large polygons lead to poor BVHs. (far more common than youβd think)
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.
Advanced Graphics β The Perfect BVH 24
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 25
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:
βͺ Threshold parameter βͺ Individual polygons are split, regardless of surrounding geometry βͺ Primitives may end up multiple times 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 26
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 27
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 28
Advanced Graphics β The Perfect BVH 29
βͺ Building Better BVHs βͺ The Problem of Large Polygons βͺ Refitting βͺ Fast BVH Construction
Advanced Graphics β The Perfect BVH 31
Summary of BVH Characteristics
A BVH provides significant freedom compared to e.g. a kD-tree: βͺ No need for a 1-to-1 relation between bounding boxes and primitives βͺ Primitives may reside in multiple leafs βͺ Bounding boxes may overlap βͺ Bounding boxes can be altered, as long as they fit in their parent box βͺ A BVH can be very bad but still valid Some consequences / opportunities: βͺ We can rebuild part of a BVH βͺ We can combine two BVHs into one βͺ We can refit a BVH
Advanced Graphics β The Perfect BVH 32
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 33
Refitting
Updating the bounding boxes stored in a BVH to match changed primitive coordinates. Algorithm:
Advanced Graphics β The Perfect BVH 34
Refitting - Suitability
Advanced Graphics β The Perfect BVH 35
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
βͺ Building Better BVHs βͺ The Problem of Large Polygons βͺ Refitting βͺ Fast BVH Construction
Advanced Graphics β The Perfect BVH 37
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 38
Advanced Graphics β The Perfect BVH 39
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 40
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 41
Binned BVH Construction
Performance evaluation: 1.9s for 10M triangles (8 cores @ 2.6Ghz).
Advanced Graphics β The Perfect BVH 42
βͺ Building Better BVHs βͺ The Problem of Large Polygons βͺ Refitting βͺ Fast BVH Construction
Jacco Bikker - November 2018 - February 2019
next lecture: βReal-time Ray Tracingβ