DistanceToNearestSurface not working.

Does anyone know why DistanceToNearestSurface works for default cube but not for the background landscape mesh?

Landscape mesh has checkbox selected to generate distance fields.

If you’re trying to get the landscape mesh ( that purple thing? ) to show the fields, then ‘affect distance fields’ should be turned off for it.

Purple thing is water and I am using Distance to Nearest Surface for foam. As you can see it works for default cube(red color) but not working for vista landscape mesh

Never really worked right for landacapes.

But you can sort of get it going. You have to make sure your landacape is also precomputing distance fields.

I believe there was a checkbox for it or a project wide setting to it.

I’d reccomend dumping the idea as a whole and using a baked texture - so its 2d.
Distance to nearest will also return vertical values.

Make a quick PP, have it paint a Z value range. Use the PP in an ortogonal screencapture.
Use the RT - if you wish to have it update at runtime - or save out the RT and use it as a texture within the material.
It’ll provide a much better result overall of where the shoreline is supposed to be.
And you will have a much better control of just how wide a foam area you want…

1 Like