Hi all, I’ve successfully implemented signed-distance-fields as described by the Valve paper:
http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
As advertised it has created excellent looking characters at very large pt sizes. However at small pt sizes (<12 or so) they look like crap. Normal 64x64 glyph simply downscaled on the left, SDF on the right.
My distance fields fonts are 64x64 pixels per character calculated from a 1024x1024 pixel original using a brute-force exhaustive distance function. Thus I figure that they encapsulate enough information to technically be able to render a good looking font event at small sizes.
(^ alpha SDF font is hard to see but provided to show that they are of high quality)
According to the creator of TextMesh Pro it is possible:
[quote]A big misconception about SDF Text Rendering is that large text looks great but small text looks bad. Well, that is not the case with TextMesh Pro’s Advanced Signed Distance Field shaders. TextMesh Pro’s SDF text looks awesome at large sizes and looks as good or better than bitmap text at small sizes.
[/quote]
http://forum.unity3d.com/threads/textmesh-pro-advanced-text-rendering-for-unity-beta-now-available-in-asset-store.227790/
Here’s the source for my fragment shader which does the basic implementation:
// GLSL 1.2 to correspond with OpenGL 2.0
#version 120
// predefined variables
uniform sampler2D tex0;
void main() {
// retrieve distance from texture
float dist = texture2D(tex0, gl_TexCoord[0].xy).a;
// fwidth helps keep outlines a constant width irrespective of scaling
float width = fwidth(dist);
float alpha = smoothstep(0.5 - width, 0.5 + width, dist);
// antialiased
gl_FragColor = vec4(gl_Color.rgb, alpha);
}
Anyway have any of you worked in this area and have suggestions towards a custom fragment shader that may accomplish this?