I don’t get a clear result when I use DistanceToNearestSurface to detect the edges around my little lake. It will be used to spawn foam around objects. Additionally I get this weird effect when I move my plane up- or downwards. Any Idea where this is coming from/ how to fix this?
Think of the distance field as a 3D texture and you’ll see that those dark grey blocks are essentially the pixels. The distance sampled by the ‘Distance to Nearest Surface’ node is the distance from the centre of each volumetric grid cell.
If you go into World Settings in the main editor window, you can increase the resolution of the distance field by reducing the value of ‘Global DistanceField View Distance’. The default is quite big. I went down to 1,000 without any noticeable hit on performance, although that will depend on the complexity of the scene.
I believe the signed distance field is only calculated within a certain distance of the camera, so once you’re too far away there isn’t anything for the ‘Distance to Nearest Surface’ to sample. Perhaps it defaults to a value (1,1,1) (white) if it doesn’t find anything, but I’m speculating a bit.
I wonder if this distance is the other setting in the Rendering section, i.e. ‘Default Max DistanceField Occlusion Distance’. Try increasing that.
This will of course make the volumetric texture bigger and so use more memory (and also more time to calculate as it will need to search for objects within that radius and add up their individual mesh distance fields, which is how the global distance field is created).
Thank you, now are the pixels smaller, but when I zoom a bit out, the material gets completely white. Any solution?
It works now, but I’m not really sure why xD. Mainly I found out that the mesh was measuring the distance to itself, that was the reason for the weird flickering. I turned off “Affect Distance Field Lighting” on my plane and now that’s fixed. For the white effect, I changed my material to the one described on the unreal page. Thanks for your help.
“There are probably other, albeit less convenient, ways to do that.”
I didn’t find a way for doing that. The Calculation of the depth of the water doesn’t work because I have no Scene Depth. (Single Layer Water Shading Model, Opaque)
“By the way, I’ve been meaning to ask - is that a poo?”
Could technically be possible…
I already tried playing around with the Settings, ‘Default Max DistanceField Occlusion Distance’ does’nt do anything. I put a screenshot in, where it shows the distance, from where it gets white, and for me it’s absolutely unusable. I tried putting it into another project, but nothing changed. I watched a few Tutorials on this, but it seems I’m the only one where this is behaving like this.
I’d appreciate any help!
Oh how aggravating. That looks an awful lot like the corner of the cube around the camera that contains the SDF. I can’t find anything that suggests how to change that distance, so it might be a hard-coded value in the engine.
What’s the intended effect? To get a faded border around objects on that plane? There are probably other, albeit less convenient, ways to do that.
By the way, I’ve been meaning to ask - is that a poo?
Ah, excellent. I’m glad you cracked it!
I am getting the same issue with the big white plane seems to do that when the camera moves away
Hey there! Any info on distance fiels for 5.0+? Looks like it’s kinda broken now.
Same test with 4.27.2 and 5.0.3
4.27.2
5.0.3
The same material applied on a plane:
In the 5.0 version, when you move away those lines are getting away but it looks so bad on close range. I want to use it to create shoreline but it makes everything jaggy and glitchy.
Tried to turn off lumen but nothing changed (that was my only guess on a potential issue).
A more obvious test: comparing Distance To nearest surface node between 4.27 and 5.0:
4.27
5.0
Like what’s going on??
Graph:
A quick remark I figured out: if you turn off Lumen in the post process volume you can adjust the “Global DistanceField View Distance” in the World settings but once Lumen is turned on this parameter will have no influence anymore. So it looks like it’s link to some Lumen parts, but I can’t find a way to fix it with Lumen parameters…Weird nobody seen that yet, since it’s there in 5.0 (so for more than a year?).
Keeping this thread alive with something. This Stair Stepping Distance Field effect still happens. My example here is just adding a scalar to the distance field. This is also in UEFN. Where there seems to be even less control over this issue.
Any Suggestions other then what has already been mentioned would be helpful.