Strange behavior of Mesh Distance Field - What am I doing wrong?

Hello folks,

I’m trying to create a material which changes if a Mesh/Object comes near to its surface.

My results were always some kind of janky and weird, so I’m tryining to figure out what is happening and where the problems are coming from.

I found this (below) in the documentation and was trying to rebuild it (without the opacity, only emissive).

(Distance to nearest surface)](

But in my scene something strange is happening. (gif) It should look like in the documentation, but I’m more then far away from it.

I’m not sure what I am doing wrong. Maybe you have some suggestions?

Gif of what is happening in my scene:

My Material:

  • Mesh Distance Field is activated
  • “Distance Field Resolution Scale” is on 10 or higher
  • Two-Sided DF is “not” activated
  • raytracing is activated
  • UE4 V26.1

Nobody got a single idea what’s going on?

distance field doens’t work well if you have meshes scaled in a non proportional way. Could it be the cause?! Also I don’t think multiplying the distance to nearestSurface is a good way to get contrast. Value close to 0 get a 10x boost, probably not what you want to do?!

Hello HoMaRt,

Thank you for your answer.

You are right. I’ve tested a lot the past days and I’ve noticed this as well. I 'm now using a lot of Cubes and other meshes in a 1x1x1 scale. But I am still experiencing the same issue.

I’ve made some changes to the materials. Maybe now you understand better what I am trying to do?

Still the biggest problem is, that the MDF is perhaps not dense enough(?). I’m not sure what is causing the issue with the self-moving faces. As you can see in the gif, the deformation of the faces, which are close to each other, is working. But when I move the couch for instance, the deformation (mask) is changing itself. That should not happen.
A few moments later in the gif you can see that the sphere which is getting close to the surface is deforming as it should. Maybe it needs some tweaking, but it is working well for a early stage version. But the self-moving surface/mask is still a big issue. I have no clue, how to get rid of it.

New Material:


Here another gif for a better understanding.

Material Notes:

I think probably what is happening is you are limited by the resolution. AFAIK distance to nearest surface samples from the global distance field, it’s much lower resolution than mesh distance fields.

You can try increasing the global DF resolution with this command:

By default I believe it is set to 128, try increasing it to 256 or 512 and see if it changes the result. Should probably go without saying but I think it is safe to assume this will have an impact on performance. In what way though, I am not sure.

Thank you for your answer,

I’ve found a post where someone was describing the same behavior. The global distance field is used for the “DistanceToNearestSurface” note.

So I lowered the value of the “Global DistanceField View Distance”. After that, the behavior of the shader/material is more in the direction of what I’m expecting.
I will also try your suggestion with the


Finally, I can go on and work on the details of the shader/material. The basics were the problem. I can think about the performance issues once everything is working. :smiley: