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?
Ray intersection with VDB?
1097 2 1- localstarlight
- Member
- 45 posts
- Joined: Jan. 2016
- Online
- Soothsayer
- Member
- 861 posts
- Joined: Oct. 2008
- Offline
- jbudsberg
- 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.
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
-
- Quick Links