Vixen
02b45cc4
csharp
public static class DistanceField

Turns an outline into a multi-channel signed distance field.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

One texture and one shader give crisp text at any scale, and outlines, glows and shadows come out of the same field for nothing. What a plain distance field cannot do is a corner: distance to the nearest edge is smooth across one, so every serif and every stem end arrives rounded. Three channels fix that — see EdgeColoring for why.

⚠ Distance to the edge's line, not to the edge's segment. Past a segment's end the distance is measured to the infinite line it lies on, weighted so the nearer segment wins — the pseudo-distance msdfgen introduced. Clamping to the segment instead rounds every convex corner back off again, which is the thing the three channels were for.

Methods (1)

  • public static DistanceFieldBitmap Generate(GlyphOutline outline, int width, int height, float scale, Vector2 origin, float range = 4)

    Builds a field for an outline.

Used by (4)

  • DistanceFieldTestsVixen.Ui.Text.Tests
  • GlyphAtlasTestsVixen.Ui.Text.Tests
  • GlyphFieldCacheVixen.Ui.Text
  • IconAtlasVixen.Ui