I have spent a few hours playing with the Distance Field Fonts, and I think I have come up with a better solution, to stomp out the jaggies.
If you add these four lines of code to the fragment shader, and comment out the
last three lines, you should get smoother rendering of the fonts.
"rcp ft2.w, ft3.w\n" + // Invert the threshold, from 0.5 to 2.0 or similar
"mul ft4.w, ft4.w, ft2.w\n" + // stretch the diminished value to the span 0-1 again
"mul ft2, v0, ft4.w\n" +
"mov oc, ft2 \n"
// Old code "mov ft1.xyz, v0.xyz\n" + // Place vertex color
// Old code "mov ft1.w, ft2.x\n" + // place smooth alpha
// Old code "mov oc, ft1 \n"
The above is for the first part of the fragmentshader code , for the tinted scenario.
The end of the second part should be:
"rcp ft2.w, ft3.w\n" + // Invert the threshold, from 0.5 to 2.0 or similar
"mul ft4.w, ft4.w, ft2.w\n" + // stretch the diminished value to the span 0-1 again
"mul ft5, ft5, ft4.w\n" +
"mov oc, ft5 \n"
to get the same effect on non-tinted quads.
I've tested this with this file:
http://www.lonesock.net/images/automati_font.png
Here you can see the font zoomed to x30 with the old code:
http://img41.imageshack.us/img41/3366/ywto.jpg
and this is with the new code:
http://img571.imageshack.us/img571/8752/2ulz.jpg
Also, remember, that you might get ugly artifacts if the font bitmap you start off with isn't large enough. It has to be really big in order for the output to be nice. Characters the size of 256px might be needed
I initially started looking into this as a potential way to get rid of jaggies in the Starling Graphics Extension, but so far, I haven't found a fast enough way to generate the distance fields. Work in progress. 🙂