patrickmeehan/moai-dev — pull request #5 by Vavius (2014-09-07 09:50:46+00:00)
Title: new SDF generation algorythm (edtaa3)

Ok, this is one more attempt to SDF generation.

My final goal is to use SDF for glyph scaling - i.e. render each glyph only once (at a small size) and display it with alphatest (or smoothstep shader for antialiasing).

The problem with current SDF implementation is binary image that is used as input. This leads to stairs artifacts. There are 3 methods to avoid this:

1. Render large sdf image, then downscale it 8 or 16 times (the Valve approach from article)
2. Don't use image, but rather glyph vector outlines to compute SDF. This is implemented in Qt 5. The most accurate approach, but hard to implement.
3. There is an algorythm that uses antialiased input image for SDF generation. http://contourtextures.wikidot.com/

So, I've took the 3rd algo and added it to MOAIImage. Code is taken from here: https://code.google.com/p/freetype-gl/

This approach gives pretty good outlines, and may be used for scalable fonts. However, it looks way more performance-hungry than current one.
Video sample: http://monosnap.com/file/bJzdH7tyaPcLrhNo1THOd1ZxeikGle

**I've added a new 3rdparty folder "edtaa3" with code. My changes to Xcode osx project aren't reflected in this pull. In order to build the project files need to be tuned to include 3rdparty/edtaa3.**