Get the latest tech news

Perfecting anti-aliasing on signed distance functions


Doing anti-aliasing on SDF is not as straightforward as it seems. Most of the time, we see people use a smoothstep with hardcoded constants, sometimes with screen space information, sometimes cryptic or convoluted formulas.

Even if SDFs have the perfect mathematical properties needed for a clean anti-aliasing, the whole issue has a scope larger than it appears at first glance. SDF of a moving pie/pacman, using Inigo Quilez formula and colorscheme for visualizationThe distance is fancily colored here for illustrative purpose, and the shape is animated to see how it affects the field. A blurry shape using a smootherstep transitionFor pixel-wise anti-aliasing, the discontinuity won't be noticed so using a linear interpolation still is a perfectly valid choice.

Get the Android app

Or read this on Hacker News