An SDF atlas cannot store a corner

The standard way to draw crisp scalable text on a GPU is to bake a signed distance field into a texture and threshold it. It is a genuinely great technique and it has one specific, unfixable failure, and knowing exactly what that failure is tells you when to reach for something else.

The same shape, zooming. Left: the field sampled into a 24 cell atlas and bilinearly interpolated. Right: the field evaluated exactly. The blue line is an outline at a fixed distance.

Watch the apex and the interior corners as it zooms in. The sampled version rounds them off and keeps rounding them no matter how close you get, because the sharpness is not in the texture to recover. The exact version stays sharp at any magnification, since there is no resolution in it to run out of.

Why the corner specifically

A distance field near a straight edge is linear, and linear interpolation between samples reconstructs a linear function exactly. That is the whole reason an SDF atlas works so well: straight edges and gentle curves survive sampling essentially perfectly, which is most of most glyphs.

A corner is where the field stops being linear. Distance to a sharp point is a cone, and bilinear interpolation of a cone gives you a rounded cone. The error is proportional to the sample spacing and it does not shrink as you zoom, so it is the one artifact that gets more visible the closer you look.

Which explains the well-known behavior: SDF text looks superb at body sizes and gets subtly mushy at display sizes, and adding texture resolution helps proportionally rather than solving it.

What direct evaluation does instead

Store the outline itself, as the quadratic Bezier curves the font already contains, and determine coverage per pixel from the curves. The usual approach computes a winding number by counting curve crossings along a ray, with a band structure so a pixel only tests the curves that could possibly affect it.

The properties that fall out:

The honest situation with Slug

The best-known implementation of this approach is Eric Lengyel's Slug, and the algorithm is published: GPU-Centered Font Rendering Directly from Glyph Outlines, Journal of Computer Graphics Techniques. The paper is readable and free.

The library is not. As of checking, sluglibrary.com sells single-engineer licenses at $1,500 and describes enterprise terms by negotiation, with no statement anywhere about open sourcing, public domain release, or a lapsed patent. There is a patent on the technique and this page is not the place to guess at its status. If you intend to implement the algorithm rather than license the library, check the patent situation yourself and do not take a blog's word for it, this one included.

That is worth stating plainly because an earlier draft of this page carried a claim that Slug was public domain. Checking the source took two minutes and the claim was wrong.

Choosing between them

Rules of thumb

  1. An SDF atlas stores a sampled field. Straight edges survive sampling exactly; corners cannot.
  2. The corner error is proportional to sample spacing and does not shrink with zoom, so it is worst exactly where you look closest.
  3. Try multi-channel SDF before jumping to outline evaluation. It recovers corners for one extra texture channel.
  4. Direct evaluation is resolution independent and data-dependent in cost. Both halves of that matter.
  5. The algorithm is published and free to read. The library is commercial, and the patent situation is yours to verify.

All 61 notes How to use them Credits