It seems that fwidth() returns a number that maps to one pixel or less. Trying it versus Stefan Gustavson's:
float aa = 0.75 * length(vec2(dFdx(d), dFdy(d)));
doesn't appear to make a perceptible difference. Can you explain how calculating fwidth() properly will give other benefits?
Anyways an update on tests so far. I've applied two improvements. The first is a supersampling technique and the second is using a "thicker" original SDF texture.
Details about the second technique. My original calculation used to create the alpha-channel texture was the canonical:
val alpha: Double = 0.5 + 0.5 * (signedDistance / spread)
Where signedDistance = distance to an opposite bit and will be +ve if inside the glyph, -ve if outside; spread = 4
And in an attempt to make the original texture "thicker" I tried the following:
val alpha: Double = 0.6 + (signedDistance / spread)
Original SDF (texture simply scaled on left, SDF shader w/ supersampling applied on right):
As you can see this gives me a much more solid-looking distance field glyph that also gives me better results with the shader esp. at small pt sizes. However, knowing that any alpha of > 0.5 (which becomes "distance" within the shader) is inside the glyph I figure I could using a more abrupt transition in the shader instead of recreating the alpha images.
I'm tending towards using the simple thicker texture because that means I can use the same texture for both SDF or simple scaling (when shaders aren't available).