Download

Direction to nearest surface?

Is there a way to get direction vector to nearest surface in material?
We have the DistanceToNearestSurface when using distance fields, but nothing regarding direction vector.
Example use case: Use the DistanceToNearestSurface and direction to nearest surface to push verts away from nearest surface. Using Vertex Normal as direction doesn’t work in most cases, where vertex normals are altered or the surface is facing the opposite side, etc.

There is an expression for that, DistanceFieldGradient.

Thank you! After normalizing it results in a direction vector to nearest surface.