Preprocessing - Build Acceleration Grid
Find bounding box
Create grid
Store each object in overlapping cells
Grid Resolution Heuristic
When do they work well: When objects are approximately evenly distributed in size and space in the scene.
When do they fail: "Teapot in a stadium" problem
Recursively divide the current octant into 8 sub-octants until the current working space is empty or the number of objects contained reaches certain minimum.
Cons:
Too many branches
Recursively divide the space using a hyperplane.
Recursively divide the space along alternating axes (
Separations don't have to be even.
Data Structure:
Internal Nodes:
Store:
Split axis
Split position
Children
No objects are stored
Leaf Nodes:
Store:
List of objects contained
Traversing a KD-Tree: If the ray has intersected with the current node, recursively check all its child nodes.
If the current node is a leaf node, test intersection with all contained objects.
Inside a partition, there may be an triangle which passes through this partition but has none of its vertices inside this partition.
An object may be contained inside multiple partitions, leading to memory inefficiency.
Ideally we want each object stored in a single node only.
Summary:
Find bounding box
Recursively split set of objects into two subsets
Recompute the bounding box of the subsets
Stop when necessary
Store objects in each leaf node
How to subdivide a node? Make the split as separated and evenly-sized as possible.
Choose a dimension to split
Heuristic #1: Always choose the longest axis in the current node
To make the partitions more evenly-spaced
Heuristic #2: Split node at location of median object
To make the tree balanced, resulting in less depth of the hierarchy
This can be done in
Heuristics are of great research interest.
Termination criteria?
Heuristic: Stop when the number of elements contained in the current node reaches certain minimum.
Data Structure:
Internal Nodes:
Store:
Bounding box
Children
No objects are stored
Leaf Nodes:
Store:
Bounding box
List of objects contained
All objects are in subtrees.
Traversing a BVH:
xxxxxxxxxx
Intersect(Ray ray, BVH node) {
if (ray misses node.bbox) return;
if (node is a leaf node) {
test intersection with all objects;
return the closest intersection;
}
hit1 = Intersect(ray, node.child1);
hit2 = Intersect(ray, node.child2);
return the closer of hit1, hit2;
}
Spatial Partition
Partition space into non-overlapping regions
An object can be contained in multiple regions
Object Partition
Partition set of objects into disjoint subsets
Bounding boxes for each set may overlap in space
Motivations and stuff to learn: Describe the light in a precise manner.
Measure system and units for illumination
Accurately measure the spatial properties of light
Radiant Flux
Intensity
Irradiance
Radiance
Perform lighting calculations in a physically correct manner.
Still based on Geometric Optics.
Definition: Radiant energy is the energy of electromagnetic radiation. It is measured in units of joules, and denoted by the symbol
Definition: Radiant flux (power) is the energy emitted, reflected, transmitted or received, per unit time.
Definition: The radiant (luminous) intensity is the power per unit solid angle emitted by a point light source.
where candela is one of the seven SI base units.
Definition: Angle is the ratio of subtended arc length on a circle to the radius
A circle has
Definition: Solid angle is the ratio of subtended area on a sphere to the radius squared
A sphere has
The area, when calculated, must be that of a part of the shell, or that projected to the shell.
Direction Vector:
An isotropic point source has an uniform intensity.
Definition: The irradiance is the power per unit area incident on a surface point.
where
Hint: Think of the
Radiance is the fundamental field quantity that describes the distribution of light in an environment.
Radiance is the quantity associated with a ray
Rendering is all about computing radiance
Definition: The radiance (luminance) is the power emitted reflected, transmitted or received by a surface, per unit solid angle, per projected unit area.
where
Irradiance per solid angle
Intensity per projected unit area
Why dividing by
To recover the true radiance from that angle (regardless of
Incident radiance is the irradiance per unit solid angle arriving at the surface.
The light arriving at the surface along a given ray.
Exiting surface radiance is the intensity per unit projected area leaving the surface.
Hint: For the two formulas for incident/exiting radiance, considering taking them has differentials and multiply
Irradiance: Total power received by area
Radiance: Power received by area
Unit hemisphere:
Reference: Bounding Volume Hierarchies (pbr-book.org)
The two primitive partitioning approaches described in the BVH section can work well for some distributions of primitives, but they often choose partitions that perform poorly in practice, leading to more nodes of the tree being visited by rays and hence unnecessary inefficient ray-primitive intersection computations at rendering time.
Most of the best algorithms (as of 2018) for building acceleration structures for ray-tracing are based on the "surface area heuristic" (SAH), which provides a well-grounded cost model for answer questions like
"which of a number of partitions of primitives will lead to a better BVH for ray-primitive intersection tests?", or
"which of a number of possible positions to split space in a spatial subdivision scheme will lead to a better acceleration structure?"
The SAH model estimates the computational cost of performing ray intersection tests, including the time spent on:
Traversing nodes of the tree
Ray-primitive intersection tests for a particular partitioning of primitives
By assuming the current working node is a leaf node regardless of the number of primitives it contains, we know that any ray that passes through this node will be tested against all of the overlapping primitives and will incur a cost of
where
We here assume that
The error introduced doesn't seem to affect the performance very much
If we split the region, rays will incur the cost
where
They can be computed using ideas from geometric probability.
For a convex volume
The algorithm then optimize the partitioning with the goal of minimizing the total cost.
Typically, a greedy algorithm is used that minimizes the cost for each single node of the hiearchy.
The bucket algorithm follows a very simple pattern.
If the number of primitives in the current node is less than a threshold, do nothing
Else:
Choose the axis to split. May split the longest axis.
Split the range on that axis into
Compute the cost if we split the node at those
Which plane is the best to patition? Choose that and recursively build BVH.
In the book,
Probably the most efficient BVH split method
Many passes are taken over the scene primitives to compute the SAH costs at all of the levels of the tree
Hard to parallelize