3 ms·
This is a great library, I used it last year for text rendering in WebGL [0]. The advantage over regular SDF is you can use lower-resolution glyph maps to achie
by haxiomic 7y ago
This is a great library, I used it last year for text rendering in WebGL [0]. The advantage over regular SDF is you can use lower-resolution glyph maps to achieve the same text sharpness. The disadvantage is that text effects like glow and stroke are tricker as you tend to get sharp edges and artefacts [1].
[0] https://github.com/VALIS-software/GPUText https://github.com/VALIS-software/GPUText
[1] https://github.com/Chlumsky/msdfgen/issues/67 https://github.com/Chlumsky/msdfgen/issues/67
- Hydraulix989 7y agoIt's also trickier to support Unicode and arbitrary fonts. I was building a 3D game for language learning on mobile, and the font rendering in Unity3D was awful (blurry and rasterized). When I eventually ended up writing my own engine, I started with bitmap fonts and quickly switched to SDF shaders. I ended up having to regenerate the texture on-the-fly as new characters were needed, acting as a cache (one of the markets was China -- you're not going to just stash all of the characters into one texture). Another wrinkle: There's also right-to-left writing systems like Hebrew and Arabic, but those weren't our markets. So far, the best I've seen is Eric Lengyel's Slug library: [1] http://sluglibrary.com/ http://sluglibrary.com/
- mises 7y agoWith respect to slug, do you know if it would be usable with something like nerd fonts (custom glyphs)? My impression is yes, but I wasn't quite clear.
- Hydraulix989 7y agoTheir demo shows it rendering color glyphs. Try reaching out to Eric?
- naikrovek 7y agoUnity purchased the company behind TextMeshPro and made it free. It is vastly better than standard Unity text rendering in every way. This is a note for future readers, and less of a reply.
- microcolonel 7y agoIf you want languages with more interesting shaping, you have to start compositing glyphs; but good shapers are out there. HarfBuzz is amazing, I'm always amazed how well random bits of Farsi and Mongolian typeset on my systems. Not sure about Unity, but it helps to be able to submit the geometry, the shader, and the uniforms, then asynchronously (or if you're lucky, in another thread) submit the SDF after you're done computing it.
- pcwalton 7y ago> The disadvantage is that text effects like glow and stroke are tricker as you tend to get sharp edges and artefacts. This is going to happen with every SDF format. The problem is that SDFs can fundamentally only encode the distance to a small fixed number of lines per texel. For regular SDF, that number is one; for mSDF, that number is two. If the complexity of the shape exceeds that (as can happen for complex fonts such as CJK fonts with small SDFs), then artefacts will occur.
- dyarosla 7y agoIn your demo [0], is there a reason for the artefact in the top left corner of the 'm' and the bottom left corner of the 'p'? Is that an artefact produced by the MSDF rendering or the msdfgen tool? [0] https://valis-software.github.io/GPUText/example/ https://valis-software.github.io/GPUText/example/
- haxiomic 7y agoIt’s a result of the MSDF technique working with small glyph textures. Bumping the glyph texture size up would remove the artefacts but I wanted to see how small I could set them and have good results at mid range font sizes