'GetDistanceToNearestSurfaceGlobal' function always returning a distance of 0.

I’m trying to make a basic ray marcher using distance fields in 4.25, but the ‘GetDistanceToNearestSurfaceGlobal’ function in a custom node always outputs a distance of 0.

I’ve definitely generated the distance fields in the project settings, as they are there in the Visualize Distance Field view mode, and the ‘DistanceToNearestSurface’ node works fine. I have also tried using 8 bit mesh distance fields and compressed mesh distance fields but neither made any difference.

The weird part is it appears to be working fine in the material preview window:

I’ve already tried multiple different meshes, using a few other versions of UE4 on a couple of different PCs, and a variant of the function called ‘GetDistanceToNearestSurfaceGlobalClipmap’ but I always get the same issue.

Any help on this would be greatly appreciated,


Having the same exact problem. Would love to see any suggestions for how to fix it

I found that the solution is to set your skylight’s mobility to Moveable. No clue why this is but it seems to fix the issue.

When something with distance fields works in one situation and not in another, it means that another doesn’t have distance fields enabled.

As far as the skylight. If you are using distance field AO, then yes, it needs to be movable.

1 Like