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

**URL:** <https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345>\
**Category:** Rendering\
**Tags:** error, Water, unreal-engine, shader, question\
**Created:** [May 1, 2017, 1:49am UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345 "2017-05-01T01:49:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knobbynobbes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Knobbynobbes](https://forums.unrealengine.com/u/Knobbynobbes)\
**Post date:** [May 1, 2017, 1:49am UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/1 "2017-05-01T01:49:21Z")

</div>

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](http://i.imgur.com/SoW7H2n.gif)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cbe433ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cbe433ac](https://forums.unrealengine.com/u/anonymous_user_cbe433ac)\
**Post date:** [May 21, 2017, 12:25am UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/2 "2017-05-21T00:25:54Z")

</div>

Having a similar problem.

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [May 21, 2017, 4:10am UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/3 "2017-05-21T04:10:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LorenzDelcol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lorenzdelcol/32/478484_2.png) [@LorenzDelcol](https://forums.unrealengine.com/u/LorenzDelcol)\
**Post date:** [July 25, 2017, 7:38pm UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/4 "2017-07-25T19:38:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pete78clark](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pete78clark](https://forums.unrealengine.com/u/pete78clark)\
**Post date:** [April 13, 2018, 10:28am UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/5 "2018-04-13T10:28:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcc52169](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcc52169](https://forums.unrealengine.com/u/anonymous_user_bcc52169)\
**Post date:** [June 8, 2018, 9:05pm UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/6 "2018-06-08T21:05:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DanielDurys](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DanielDurys](https://forums.unrealengine.com/u/DanielDurys)\
**Post date:** [March 27, 2019, 4:06pm UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/7 "2019-03-27T16:06:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Clazzid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Clazzid](https://forums.unrealengine.com/u/Clazzid)\
**Post date:** [May 25, 2025, 11:58pm UTC](https://forums.unrealengine.com/t/distance-to-nearest-surface-node-not-working-only-returns-0-need-fix/392345/8 "2025-05-25T23:58:27Z")

</div>

In recent versions, it seems you need to disable “Affect Dynamic Indirect Lighting” for this to work
