5 ms·
Glyphs are rasterized once and stored in a texture atlas. When rendering a glyph, the fragment shader pulls from that texture. Once loaded, the glyph stays load
by jwilm 10y ago
Glyphs are rasterized once and stored in a texture atlas. When rendering a glyph, the fragment shader pulls from that texture. Once loaded, the glyph stays loaded for the duration of the program.
- vvanders 10y agoGot it, just a heads-ups that texture atlas tends to hammer your GPU texture upload if you want to support UTF or non-latin(esp glyph-based) character sets. Not trying to be discouraging just something to keep in mind if that's a direction you want to go. Pretty excited to see a GPU + Rust based stuff making it out into the wild.
- valarauca1 10y agoQuestion: With a modern discrete GPU card wouldn't the texture atlas just end up in it's VRAM as cards these days commonly have >1GB of VRAM? (Sorry if this is a stupid question, still trying to grok opengl)
- vvanders 10y agoSure, but you're either going to have to generate the whole font up-front(can be many thousand characters) or you need to re-upload as you use/generate new characters which can thrash unless you're very careful about the regions you lock(and you have a driver that behaves appropriately). Most font renderers I know do a tiered LRU cache of 3-4 texture "pages" which hurts your drawcall batching but tends to be a nice tradeoff in texture usage.
- valarauca1 10y agoOkay so I dug into this. There is a font cache on the GPU and another in CPU ram. I believe it will fall into the drawcall batching issue you are concerned about... but terminals don't need to get >60FPS in most cases.
- saurik 10y agoYou really have nothing better to render on your GPU and store in that video memory than your terminal? I also use a web browser, and feel like it could use a performance boost a lot more than my terminal (particularly as I don't actually believe that using textures in this way is actually the most efficient way to render fonts with OpenGL).
- enqk 10y agoWhat's your currently preferred way to render text with OpenGL?
- vvanders 10y agoThere's Distance Fields[1] and Loop-Blinn[2] aside from standard textures that I'm aware of. Valve uses the first, very few people use the second because of patent issues. They're more computationally expensive in some cases so there's always tradeoffs to be made depending on your hardware. [1] - http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_... [2] - http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html
- deleted 10y ago[deleted]
- kickscondor 10y agoAny idea how much memory it takes to store the full atlas for a font with full Unicode/emoji support? Also does it work for colored emoji?
- vvanders 10y ago~95k UTF characters x font sizes x font styles(bold, italic, etc) x outline size. It's pretty large.
- the8472 10y agoDon't combining characters, ligatures or scripts that fuse characters lead to a combinatorical explosion? can it handle zalgo?
- chongli 10y agoTerminal emulators tend to prefer fixed-width fonts so you don't really have to worry about those too much.