SDF seems to be one of the better solutions for text rendering.
Valve had this problem solved since 2007. I'd argue this technique is a big part of what gave TF2 its impressive visual style. That game ran at 100+ fps on hardware like the 8800GT at the time.
I wonder how the GPU version is implemented. One quad and one texture draw per glyph sounds very not scalable, but one quad per terminal, one texture atlas and one shader to draw glyphs from the atlas already sounds much better.
That's nothing for a modern GPU. For example, this benchmark[1] says to expect on the order of 10-800 million tri/s. At the low end of that, you'd have a frame time of 3.427ms -- 292 fps.
The original Playstation could do 180 000 textured polygons per second[2], so it could've managed ~5 fps. Of course, you wouldn't render that many chars at its available output resolutions anyway. :)
Caching the fonts to a texture atlas is not an unusual idea. https://github.com/memononen/fontstash is a well known example of this. Odin has a native port meant to work in conjunction with its bindings to NanoVG. The Odin code is coupled to stb_freetype.
> So I tried something unconventional: draw each character once, cache it as a texture, and then just copy those textures around.
That’s more like the most conventional way to draw characters ever. Nobody goes around rendering filled Béziers any more than absolutely necessary. And conventionally conventionally, fonts were bitmaps in the first place!
16 comments
[ 4.1 ms ] story [ 55.8 ms ] threadhttps://github.com/microsoft/terminal/issues/10362#issuecomm...
A way faster terminal emulator demo: https://github.com/cmuratori/refterm
And a terminal rendering benchmark tool: https://github.com/cmuratori/termbench
Valve had this problem solved since 2007. I'd argue this technique is a big part of what gave TF2 its impressive visual style. That game ran at 100+ fps on hardware like the 8800GT at the time.
https://www.redblobgames.com/x/2403-distance-field-fonts/
[1]: https://news.ycombinator.com/item?id=45580559
The original Playstation could do 180 000 textured polygons per second[2], so it could've managed ~5 fps. Of course, you wouldn't render that many chars at its available output resolutions anyway. :)
[1] https://github.com/ctsilva/triangle-rendering-benchmarks#:~:... [2] https://en.wikipedia.org/wiki/PlayStation_technical_specific...
That’s more like the most conventional way to draw characters ever. Nobody goes around rendering filled Béziers any more than absolutely necessary. And conventionally conventionally, fonts were bitmaps in the first place!
https://github.com/Chlumsky/msdfgen
and
https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007...
The context is GPU's, things like three.js
But yes, drawing text is hard.
https://faultlore.com/blah/text-hates-you/