DistanceToNearestSurface node not working properly

Hello, I am having issue in my water + foam material that I cannot figure out myself. I created this material in my test project, everything was working fine. Then I migrated this effect to its own project and now the distance to nearest surface calculations stopped working.

Generate mesh distance fields is set on, I have all on Epic, the plane I am using water material on is having no shadows.

But the weird thing is that when I turn on Mesh Distance Fields visualization, everything starts working - but when turned off, its back to “normal” (foam everywhere, not just at the edges).

Here is the graph nodes I am using for calculation distance to surface. The calculation always returns 1 I guess.

I haven’t used the node before but wouldn’t you have to plug something into the Position in order for it to know where to start from? Typically if you leave a pin empty then you’re not providing it with any info, hence it reads as Zero.

https://docs.unrealengine.com/en-us/…erence/Utility - Use the side menu on the right to jump to Distance to Nearest Surface. You need to feed it a World Position.

You also have to enable Mesh Distance Field generation in your Project Settings for this to work.

You need to set Mesh Distance Fields in your project settings for that node to work!

Good Luck!

**EDIT: I can confirm that if I add in a landscape, it will break the distance to surface. I have a scene with it working fine, around a cube, then when I add a landscape actor, the effect breaks. I’ve tried moving the water plane far away from the landscape, and it’s still broken. If I view the global distance field, it’s broken when the landscape is set to visible.

It could just be an issue with my machine because for some reason, landscapes always seems to break the global distance field for me. Try testing this out on your end **@KarelOtruba

Open the plane static mesh, search for distance field, check generate distance field, save. It’s off, by default, on the default plane mesh that comes with the editor.

Hello again! As I said in my first post, I have all set up correctly (Generate Mesh distance field in project settings). Also, that nodes takes Absolute world position by default, if not provided.

The problem was as @IronicParadox said, I have deleted my landscape (I didn’t need it either way) and it all started working. I thought that landscapes should not affect the generated Mesh Distance Fields.

Thanks a bunch!

Well that solves one problem, I guess. However, there is still the standing issue of landscapes breaking the global distance field. I’m curious, what GPU and driver version are you using?

Currently I am using NVIDIA GeForce GTX 1060 6GB with the latest drivers (version 398.36 from geforce.com)

As far as I know, landscapes were added to the global distance field quite a few releases ago. This might be a bug. I can definitely say that it’s breaking the global distance field for me because when I have the showflag for it enabled and a landscape enabled, it all turns black. If the landscape is hidden, it all functions properly again.