DistanceToNearestSurfacec Exclude Mesh from results without disabling Distance Fields for it?

Essentially I want to use a material on a mesh that make use of DistanceToNearestSurface but in order for it to work the results of the DistanceToNearestSurface needs to exclude its self.

The issue there is, I want this mesh with this material to get the distance fields from other meshes with the same material but if I have to disable affects distance field on the mesh then I can’t do this.

How can I keep my cake and eat it too?

I though about maybe doing a conditional check where if the DistanceField result is of a certain distance, ignore that and then when it exceeds it use the result but this didn’t seem to work as i thought it would.

As far as I know the distance field has no way to distinguish whether the nearest surface is itself or something else. But you can sample the distance field from a different position. It’s common to offset the sample point (often along the vertex normal) from the mesh.

2 Likes

Yeah I just did this and it seems to work for me for now. Thanks.

I know this was a while ago, but how did you change the offset and resample?

How did you solve it?

1 Like

The node gives you the chance to sample from a different point

image

So you can start further out than the edge of your mesh, by doing

1 Like