Distance To Nearest Surface Node not working, only returns 0. Need fix!

The mental pain is real… I’ve been trying to get what I thought was a simple effect going in a material, but no matter what I do, nothing works. All I want to do is to use the distance-to-nearest-surface node in a water shader, but it only ever returns 0. I’m losing my mind as to why this isn’t working.

My graph is literally just absolute world position → distance to nearest surface → divide by 100 → lerp between red and blue → base color output. I don’t know what else I should be doing, as this is even what the documentation says should be working. Anyone know what I need to fix?

Goal: make some water that looks like this:
http://i.imgur.com/SoW7H2n.gif

1 Like

Having a similar problem.

Distance to nearest surfase is distance field function, so, to use it, make sure that “generate distance field” enabled in your project.

have you tried putting your engine scalability to “epic”? Distance to nearest surface only works on epic resolution.

Did you get anywhere with this? I’ve looking at something very similar just now and running into the same issues.

Distance Fields are disabled for computers with Intel Graphics Cards because it causes them to hang, I had trouble with this as well but I looked at the official documentation and there it said what I just told you. If you have an Intel Graphics Card then the problem is likely your computer and not your code or the software itself.

shadows setting needs to be set minimum to high for me to see effect