Updating Volumetric Data Based On Raycast Results

I have a model stored in a GVDB representation, and would like to cast rays through the scene and then update values in each of the voxels (including voxels that do not contain the occupied space) based on the number of rays that passed through that voxel. I have seen examples like Spray Deposit where the hit points of the rays are updated, but none where each of the voxels that the ray passes through are updated with a new value. Is there an accepted efficient way to update voxel values based on ray pass through? Do any examples exist that do this?

Thanks for any insight,
David

This is a rather specialized task, so there a no samples that currently do this.
There are a few different ways to approach this:

  1. You could write your own custom raytracing brick function, using the rayDeepBrick as a starting point, and modify it to also update the volume during raytracing by doing surfWrite at each sample. Simplest.

  2. Another way would be to use the gvdb.Raytrace function to get the direction and hit point. Then, you perform a second pass with your own compute kernel that would modify voxel values along each ray. The number of threads launched would be the number of samples for each ray, multipled by all rays.

  3. Yet a third way would be to launch a custom compute kernel over all voxels, and then measure the distance the voxel to each nearby ray.

The first and second are called scatter methods, and while simpler, they suffer the problem that multiple rays can write to the same voxel, thus creating conflicts that are not easily resolved. The third method is called a gather, and has the benefit of allowing you to merge nearby rays into voxels however you like, but is more difficult to implement.

Hi, I know this is an older thread but I am also interested in this.

Has there been any advancements since 2017 ? Is this function part of OptiX/GVDB integration ?

Thank you,