Closed ethanleau closed 4 years ago
You are correct--nice catch!
I think that's an artifact from an early version of that code, where I wanted to try high resolution voxelizations. In that case, it'd be a lot of wasted memory for all of the empty voxels that didn't have geometry in them, so the idea was to use a hash table. It's now very silly to allocate 4x more voxels than will ever be necessary for the hash table.
FWIW this turns out to be a not great way to sample lights; the Conty and Kulla paper from EGSR 2018 on many light source sampling works much better (and that, or something like it, will replace this code in the next version of pbrt.)
Closing this, since that code is effectively obsolete for the future.
In "src/core/lightdistrib.h(.cpp)",
SpatialLightDistribution
use a hash table to record light distribution in each voxel. I wonder if a simple array is enough.For example, each element in this simple array is (simliar to
HashEntry
):And to index a point(
Point3f p
), we justThen we can get the ditribution using atomic operations