When I visualize Distance Field Ambient Occlusion in the editor, I can see the correct shape of objects.
However, when I try to do something similar with a material using DistanceToNearestSurface, the shapes look strange. Also I would expect to see a gradient and not only black and white.
It feels like I’m not understanding distance fields correctly. Can anyone point me into the right direction?
‘Distance to nearest surface’ is going to return the distance in centimeters. Since you are clamping the value between 0 and 1, it makes sense that you’d basically see no soft transition between black and white
Scale the value by multiplying it with some small number (like 0.001) to get a softer transition.
In the pictures above, a static mesh plane is intersected by a sphere, cube and cone (all with a transparent material). The DistanceToNearestSurface-Material covers the static mesh plane. So, for the lerp alpha should be ~0 at the intersection areas such that they are painted white. But it’s just the other way around. Why is that? How can I modify my material, such that the intersection areas are precisely colored?
I believe that this can be achieved by covering the static mesh plane with my DistanceToNearestSurface-material if I configure it in the correct way.
I.e. following the logic:
IF inside sphere/cube/cone
THEN color = red
ELSE color = white
It should be possible to determine “inside” using DistanceToNearestSurface, right?
I hope this is clearer now. Otherwise please tell me and I will try to clarify more.