How do Distance Fields work in materials?

You’re correct. The material is sampling the distance field (some kind of 3D Texture) and therefor it cannot detect what objects it is sampling. That would require a seperate distance field texture for each object and that would have a quite noticable effect on performance.

So in fact these are no atrifacts or errors. This is the way it should behave and as you can see it is doing so very well.

A workaround to prevent an object from sampling itself is to multiply the vertex normal by some amount and add it to AbsoluteWorldPosition. Put that into the position input of either of the two nodes. This will reduce the precision quite a bit but at least the object is not sampling itself anymore.

75600-distancefieldoffset.png

I found this workaround somewhere in the forums I think but unfortunately I can’t find the thread anymore.

Hope this helps.

6 Likes