New information and a potential solution. But first a summary just with some fresh examples of what has been stated earlier.
For reference here’s what a basic material referencing the DistanceToNearestSurface looked like in UE 4.7. You can likely tell I’m working towards a raked gravel type effect, this is just the debug for setting that up.
Now compare that to how the exact same setup looks in UE 5.3:
These look different enough that you could be forgiven in assuming that I’m just doing something wrong. That’s what I assumed too. In fact the whole reason I made the 4.7 project was that I could swear I had something like this working 10 years ago.
So before we talk solutions it’s worth sharing why it is that 5.3 looks this way. The answer is that Unreal 5+ introduces the idea of a Global Distance Field. And DistanceToNearestSurface uses that. And with default project settings the Global Distance Field is incredibly crude.
The first image is my Mesh Distance Field, you can see it’s fairly precise. The second image is my Global Distance Field. It is sparse enough that’s it’s functionally useless in a shader like this. The Global Distance Field takes the in the raw data from the Mesh Distance Field and makes a much more optimized version of it.
Changing the project settings for how detailed your mesh distance fields are will not change this, as the Global DF will still down-sample it. Similarly changing resolution settings at an individual mesh level will not change the Global DF either.
If you need to keep your project in Unreal 5.3 etc there’s only one way I’ve found to adjust this: you must disable lumen and then and only then can you change the Global DistanceField View Distance from its default of 20,000 to something more precise.
The earlier results were at the 20k default, here are the results at 10k, 5k, and 2k respectively:
Of course this creates issues where as you get lower and lower you may now start to have clipping problems. Because that View Distance is also the maximum distance at which your SDF renders:

If like me you’re using that for a shader then your shader will be receiving a value of 0 on anything outside the range. So if your project doesn’t need Lumen and if you can find a value range that gives you a good tradeoff in precision vs clipping then that’s the fix.