I took a short vacation last week and I spent some time reading about different topics. I came across a book titled OpenGL Insights which included a very educating chapter written by Stephan Gustavson about text rendering using signed distance fields. In his paper, Stephan proposes a different approach for computing the distance map:
The new antialiased Euclidean distance transform is a straightforward extension of traditional Euclidean distance transform algorithms, and for the purpose of 2D shape rendering, it is a much better fit than previous methods. It takes as its input an antialiased, area-sampled image of a shape, it computes the distance to the closest point on the underlying edge of the shape, and it allows fractional distances with arbitrary precision, limited only by the antialiasing accuracy of the input image
He also provided an implementation for the book using a 16-bit depth value for the depth map, which is a much accurate format than the one I use in my current implementation (8-bits). In addition, his fragment shader interpolates the distance value for every pixel and its neighbors, producing much better end results.
I’m currently in the process of enhancing my implementation based on Stephan’s approach. To be honest, I still don’t understand much of the algorithm, but so far the results are very promising: