I’m trying to create a material, that will outline the intersection with another object. I was able to make it work with Distance Field but the result looks really choppy. On the internet it’s said that You have to increase the “Distance Field Resolution Scale” which I tried. But even though I set the value to maximum it’s not changing anything. I tried all kinds of stuff that I was able to find on the internet but nothing seems to work.
Can someone help?
There are actually two distance fields - a global one which is sampled when you do a DistanceToNearestSurface node (which is what I assume is being used in your first image) and a per-object one which is used by Distance Field AO / Ray Traced Distance Field shadows, and also to build the global distance field.
The resolution of the global distance field is going to be the limiting factor, since it’s a volume texture mapped onto the entire area around your camera. You can control it with r.AOGlobalDFResolution and r.AOInnerGlobalDFClipmapDistance. Beware of raising the resolution though, volume textures get huge really fast!
Is there a way to reference the per-object distance fields in a material somehow?
Not at the moment, but it could be implemented in the future. It’s a bit trickier because the per-object distance fields have to be culled down to the point in space that you want to query them.
DistanceToNearestSurface and “Global DistanceField View Distance”
Oh man, thank you so much! As you assumed we are using DistanceToNearestSurface for the material and by changing “Global DistanceField View Distance” (in the UI dialog) from in our case 20.000 to 5.000, the shader is now exactly doing what it’s supposed to be doing. Perfect! Thanks a lot!
I apologize for a dumb question, but @InScene , but I’m not finding the “Global distancefield view distance” setting over here. Do I need to enable something somewhere? I’ve already enabled the distance fields in the editor settings. I’ve got the “DistanceToNearestSurface” node working (it looks like it does in your original screenshot.)
I just can’t find the view distance setting you show in your latest post.
Is this perhaps because I’m still on 4.9 ? What Version are you on?
we’re using version 4.11 and 4.12. I’m quite new to unreal engine development, so I can’t tell if the option only exists in the newer versions.
I’ve also activated the option “Generate Mesh Distance Fields” which you can find in “Project Settings -> Rendering -> Lighting”. But even if it is disabled, the “Global DistanceField View Distance” parameter is visible at “Windows -> World Settings”.
So maybe you should try to update to a newer version. Maybe @DanielW knows more about this as he seems to be an unreal developer.
‘Global DistanceField View Distance’ was added to WorldSettings more recently, I think in 4.12.
Ah, I see. Thank you guys! I guess I’ll have to move my project to a newer version