AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Apache License 2.0
2.71k stars 660 forks source link

Openvdb closest point query #1616

Closed MarcoWang1 closed 1 year ago

MarcoWang1 commented 1 year ago

If I have an openvdb grid, can I do closest point query ?(calculate the closest point in the 0 isosurface of a random point in the narrow band level set )

apradhana commented 1 year ago

If the grid that you have is a level-set/Signed Distance Function (SDF), you can compute the normal corresponding to the SDF and store it in as, say, a Vec3S grid. The closest point in the surface is given by the point_position - sdf * normal value at your query location.

MarcoWang1 commented 1 year ago

how to compute the normal corresponding to the sdf?

richhones commented 1 year ago

This the normal of an SDF is the negative gradient of its values e.g. https://shaderfun.com/2018/07/23/signed-distance-fields-part-8-gradients-bevels-and-noise/