CCDistanceMapGenerator

CCDistanceMapGenerator is a tool you can use to generate distance maps from textures. It uses the alpha channel of the source texture, considering every pixel with an alpha value of 1 to be inside and every pixel with an alpha value of 0 to be outside. Pixels with any other alpha value are considered to be on the edge.

It is especially useful for processing font atlases, but can be used with any texture that contains anti-aliased inside-outside information in its alpha channel.

The tool can be found inside Unity under Window / Distance Map Generator.

You can see a short demonstration video here.

Keep the licence in mind if you consider including this tool in a distribution. Make sure you fully understand the GNU GPL.

Selecting a Source Texture

If opened without a texture selected, the generator is rather empty. Use the Source Texture field to select the texture you want to generate a distance map for.
no texture selected
texture selected
If you had a texture selected while opening the generator, that texture will be assigned to Source Texture by default.

Make sure that the source texture is readable. You do this by switching the Texture Type of the source texture to advanced and check Read/Write Enabled. Also make sure to set the Texture Format to something with an alpha channel and without compression. Don't forget to hit Apply. You only need these settings while generating the distance map, you can change them back later, which is a good idea if you don't need the texture to be readable.

For best results, make sure there aren't any edges touching the outside of the texture.

Generating a Distance Map

With a source texture selected, you will be able to press the Generate button. This will compute a distance map and display its alpha channel. The texture will have the same size as the source texture and contain the distance information in its alpha channel. The window will resize to fit the texture.
texture generated
After generating, you're able to press the Export PNG file button. This allows you to save the distance map to a PNG file and import it into Unity. By default, the exporter places the file in the same directory as the source texture, with " distance map" appended to the source texture's name.

RGB Mode

RGB Mode controls how the RGB channels of the exported texture are filled. There are four options.
White
Set the RGB channels to 1, resulting in white.
Black
Set the RGB channels to 0, resulting in black.
Distance
Set the RGB channels to the same value as the alpha channel.
Source
Copy the source RGB channels.

Inside and Outside Distance

Inside Distance and Outside Distance control how far from the edge pixels are considered to be either fully inside or fully outside. This distance is measured in pixels.

If both values are greater than zero, pixels right on the edge will get an alpha value of 0.5. Inside the edge, the alpha values increase linearly until they reach 1 at Inside Distance. Outside the edge, the alpha values decrease linearly until they reach 0 at Outside Distance.

If Inside Distance isn't greater than zero, all pixels inside will get an alpha value of 1. Notice that in this case, alpha values of 0.5 aren't on the edge, but halfway between the edge and Outside Distance.

only outside
If Outside Distance isn't greater than zero, all pixels outside will get an alpha value of 0. Notice that in this case, alpha values of 0.5 aren't on the edge, but halfway between the edge and Inside Distance.
only inside
If both distances aren't greater than zero, nothing is computed.

Post-process

Post-process controls whether any post-processing is done on pixels close to the edge. It sets the maximum pixel distance at which this post-processing occurs, both inside and outside the edge. The difference might be subtle or virtually nonexistant. It might even make it look worse. Typically you won't post-process further than 3 pixels away from the edge, if at all.