The technique is described in this paper published by Valve:
See also this forum topic, which has screenshots:
Remove broken use of unneeded atlas
Add DistanceFieldEffect to Hiero
This can be used to create signed distance fields, for generating fonts
that remain crisp-looking even at high magnification when rendered with
See the Valve paper:
Add a test that shows the use of distance field fonts
Extract distance field generation into a standalone class
Also make it runnable as a command line tool
Awesome! I wanted to play around with distance fields for ages. I think your way of adding the functionality is great. I wonder if we should add the shaders to the default distribution in some way. I could give BitmapFont a shader that it uses when it's rendered, and a flag in BitmapFontData.
I guess as a first step this is sufficient and folks should supply their own shaders, based on your example. I'd welcome a wiki article, don't want to ask for to much.
Nate has to sign off the changes to Hiero, they seem rather unintrusive to me though.
Thanks Mario! My initial thought was to add the shaders to the core library, but I decided against it to avoid bloat. Also, there are many cool tricks you can do (outlines, shadows, glows) so many people will want to provide their own anyway.
Also, you need to provide the scale at which the font is rendered to the shader, so it's not entirely hands-off just yet. If you know a way in GLSL to determine the "magnification" of a texture, I'm all ears! It must exist in the GPU, because somehow it can choose mipmap levels, but I can't seem to find this functionality exposed in GLSL. If you know better, please enlighten me and I'll roll a uniform shader for inclusion in BitmapFont.
As to that wiki article, that was totally already planned and I just wrote it: http://code.google.com/p/libgdx/wiki/DistanceFieldFonts
Fantastic. I agree with your thoughts on not integrating any shaders just yet.
I'm not aware of a way to query the magnification level of a texture sampler in GLSL i'm afraid. It's just a black box, like the other sampler filters iirc.
The Wiki article looks cool, thanks for that! Once this is properly integrated i shall write a small blog post on the matter referencing the article.
Just waiting for the Nate now :)
Looks good to me! And a wiki article too? Woohoo! Since it seems we all agree, merging.
Awesome, thanks guys!