How does one anti-alias a procedural material in the general case?

Guides such as this one which describe how to anti-alias procedural materials always assume that the calculation of an average pixel colour is trivial (or sufficient). But what do you do when you need to average more than just a base colour? For example, I’m working on a displacement mapping shader that suffers from obvious staircasing on the extruded surfaces, since their edges are determined by texel density rather than pixel density.

  • I can’t average neighbouring UVs because that would distort the projection
  • I can’t average neighbouring texel colours because they aren’t the issue
  • I can’t average neighbouring normals because that would imply a surface slope where there is none

It seems my only option is to perform anti-aliasing on the final material output after speculars etc. are calculated, but is that even possible in the material editor? Or am I going about this all wrong?

Hi. Can you show screenshots?

Are you using “if”, “floor”, “ceil” or some similar math, that is the cause of completely hard edges? Otherwise you can use a function with a slight slope. For example, remap the range from 0.49-0.51 to 0.0-1.0 (with a node like that http://www.danielelliott.co.uk/2016/05/05/super-useful-ue4-remap-material-function/ ), then of course clamp it to 0-1.

Regards,

Oskar