GPU Font Rendering with Slug: Dynamic Dilation and MIT License Release
The Slug algorithm, developed in 2016, enables direct GPU rendering of fonts and vector graphics from Bézier curves without texture atlases. Over the past decade, it has evolved with a key upgrade—dynamic dilation—and its patent is now open for free use under the MIT license.
Evolution of the Slug Algorithm
Slug tackles the challenge of reliable, fast, and high-quality real-time text rendering. Reliability means no missing pixels or artifacts, performance keeps FPS steady even on 2016-era consoles, and quality delivers smooth curves and crisp edges at any scale or perspective.
Since its publication in JCGT in 2017, the code has seen several refinements:
- Removed stripe splitting optimization, which sped up large glyphs but caused shader divergence and doubled data volume.
- Dropped adaptive supersampling, as its benefits were only noticeable on barely legible text, while dilation effectively handles aliasing at small sizes.
- Overhauled multicolored emoji rendering: swapped pixel shader loops for independent glyphs with their own bounding polygons, simplifying code and boosting performance.
These changes streamlined the pixel shader, cut data usage, and enhanced overall rendering efficiency.
Dynamic Dilation: Automatic Optimization
Before dynamic dilation, users had to manually set a fixed offset for expanding glyph bounding polygons. This caused aliasing artifacts at small sizes and wasted GPU resources at large ones. Dynamic dilation fixes both by automatically computing the optimal offset in the vertex shader based on the model-view-projection (MVP) matrix and viewport dimensions.
The calculation ensures partially covered pixel centers fall inside the polygon for proper rasterization, without excess fill. The formula derives from expanding by half a pixel in viewport space and solves as a quadratic equation:
d = (s³t + s²√(u² + v²)) / (u² + v² - s²t²)
where s = m₃₀p_x + m₃₁p_y + m₃₃, t = m₃₀n̂_x + m₃₁n̂_y, and u and v are derivatives from MVP parameters and the normal. The "+" sign yields the outward offset along the unit normal.
To preserve the original glyph size, sampling coordinates on the mipmapped surface are adjusted using the inverse 2×2 Jacobian matrix, transforming the offset into object space.
Patent Release and Licensing
In 2019, the author patented the Slug algorithm, but it's now released for unrestricted use under the MIT license. Developers can integrate it into projects without legal hurdles. Slug has already been licensed by companies like Activision, Adobe, and Ubisoft for video games, scientific visualization, CAD, and more, proving its real-world value.
Key Takeaways
- Slug renders fonts and vector graphics directly on GPU from Bézier curves, delivering reliability, speed, and top-tier quality.
- Dynamic dilation auto-optimizes bounding polygon expansion, eliminating artifacts and resource waste.
- The algorithm has evolved: stripe splitting and supersampling removed, emoji rendering simplified.
- Slug's patent is now MIT-licensed for free use in commercial and open-source projects.
- It's battle-tested in gaming, scientific viz, CAD, and beyond.
— Editorial Team
No comments yet.