How do Distance Fields work in materials?

Notminor
Thu, 26 Nov 2015 00:01:24 +0000
Rendering

So I want to use the material expressions “DistanceFieldGradient” and “DistanceToNearestSurface”.
They work great straight out of the box, except one minor detail.
There are some gradients and artifacts and I have no clue where they come from and how to remove them.

First the “DistanceToNearestSurface” :

The intersection of the cube with the floor(a cube as well) is noticeable. But why are the sides red where no other surface is near or even intersecting?
The material for the cube is an exact copy of the one that can be [found in the documentation][2].

The generated distance fields look good as far as I can tell.

Something similar but not the exact same is happening with “DistanceFieldGradient”:

Again the intersection is noticeable but kind of very difficult to use with those other gradients overlapping them.
On more complex meshes they are all over the place.

The material setup is quite simple:

Any suggestions where they come from and how I can get rid of them?

3 posts - 1 participant