Antialiased Step Material Function.

Hey folks, I came across blog post recently and thought others may be interested in it as well. Basically, it talks about antialiasing distance fields, or any gradient really. Normally, in the past I’d use Step or Smooth Step to threshold these gradients. But this always resulted in ugly aliasing. The blog post described how to combat this, and I spun up a quick material function to implement it and was happy enough with the results I thought I’d share.

I’ll let the comparison speak for itself:
Slider Comparison

Here’s a pastebin with the MF nodes

The SDF works just like the Y on a step.
Threshold works like the X on a step.
Width acts kind of like the range between min and max on a smooth step if you want to soften the edge a little bit.

Anyway, hopefully this is useful to someone.

Edit: In case you have issues with the slider comparison, here are the images:
Regular Step Function:


Screenspace AA Function:

1 Like