Distance to Nearest Surface not working in procedural generated content


I have static meshes dragged out from the content folder to the scene and tested to be working.


However, for the same world, i have procedurally generated a landscape of static meshes(HISMC) and expected the same meshes to generate distance field but it did not work.


And some other (few) meshes(HISMC) that were created procedurally as well, were generating the distance field. Is there a setting thingy that i need to do to get it working for all? Using unreal engine 4.22.3 .

Just like for the static meshes you have to make sure the distance field checkbox is marked.

In the end however I did away with the distance field and used a mapping of the terrain taken after basic generation as the underlying texture to shift colors.

Its not quite the same, but writing 1 render texture and using it in absolute world position is a lot less intensive on the gpu.
The downside is the pixelation, the max you get is a 4k texture to cover up the whole landscape, so the water material has to make use of a few smoothstep passes to refine the areas. Still less intensive then distance fields though (also because distance to nearest surface seems to be linked to camera proximity).

Thanks for the advice. I have tried it but cant get the camera settings to project it correctly via triplanar for multiple sea planes. And as you have mentioned it would appeared to be pixelated at far camera projection distance.

I have managed to solve my problem though. The issue was i have disabled the shadows for shore HISMCs which disabled the distance field (distance to nearest surface node in material). Enabling the shadows popped the distance field back.

I will keep in mind on the approach that you have mentioned. Might be useful in future.

Tips : for those trying to get distance field to work for static meshes. Make sure it is fully enclosed mesh.

I was having issues with this again - and turns out aside from following my own advice from above, you also now have to uncheck “Affect Distance Field Lighting” on the mesh you want to use the Distance To Nearest Surface (or gradients) on.