Ray intersection with VDB?

   1092   2   1
User Avatar
Member
45 posts
Joined: Jan. 2016
Online
Given a point, a direction vector, and a fog VDB, what is the best way to find voxels intersecting along the vector? I would ideally like to be able to find the first and last intersections if possible.

I hacked together an imprecise method by turning the VDB into a mesh and then using the intersect VEX function on the geometry, but its lack of precision is not ideal.

Is there a way to do this easily?
User Avatar
Member
861 posts
Joined: Oct. 2008
Offline
volumearrivaltime might help you but it's pretty old school. It's not exactly along a straight vector but depending on what you do it might be even cooler. vdbadvect can do a similar thing.
Edited by Soothsayer - March 22, 2023 08:02:22
--
Jobless
User Avatar
Member
92 posts
Joined: Aug. 2010
Offline
depending on your use case, you shouldn't need to do a real trace.  consider taking the vector rejection of the voxel vector (voxel center to ray position) and ray vector.  if the vector "rejection" length is less than the voxel size you have a hit. if you need the hits sorted, sort by the vector "projection" length.



EDIT: ack! I have the group backwards in my GIF, but you get the idea.  note if you have a transform on the VDB, you can invert both the VDB and ray vector by the VDB xform.  Then your VDB is axis-aligned so the point XYZ positions are equal to the voxel_ijk.
Edited by jbudsberg - July 12, 2023 18:26:45

Attachments:
vdb_intersect_01.gif (1.6 MB)

  • Quick Links