Understanding distance fields

When I visualize Distance Field Ambient Occlusion in the editor, I can see the correct shape of objects.

75726-distancefield.png

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?

Thanks. I see the transition now.

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?

The initial problem I had is described here: https://answers.unrealengine.com/questions/350101/is-it-possible-to-draw-objects-which-are-sliced-by.html

With “regular” materials, you can see how the static mesh plane intersects the sphere, cube and cone:

In my case, the sphere, cube and cone are transparent/invisible. I depict this with a grid:

76081-transparent_objects.png

I would like to paint the area where the static mesh plane intersects the sphere, cube and cone, like this:

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.

The visualization of the DFAO seems reasonbly accurate to me. Or do you have any idea how I could solve my problem otherwise?

Have you figured this out?

Unfortunately no.

Try upping the distance field resolution by a HUGE amount on the meshes?

FWIW, scaling up your meshes will make the intersection cleaner, but as you can see, it’s still imprecise near the angles.

Here the cone is using a scale of (10, 10, 10).