What SDF Format to use

Parent Previous Next

What SDF Format to Use


SmartEdge supports Signal Distance Fields (SDF) as well as Multi-Channel Distance Fields (MSDF and MSDFA). For each of this formats, it uses multiple algorithms to generate the textures. Next is a list of them and cases when you should prefer one over the other.


Generators


The two main algorithms used are a Raster based generator and a Geometry solver. They both allow generating SDF textures, and can be selected from the quality popup in the SDF Font Maker.

SDF

Selecting this option generates an SDF texture using the Geometry Solver. This is really fast and produces high quality borders so most of the times, this is the preferred SDF option.

However, this solver doesn't validate the font for errors which makes it really fast, but there will be fonts with bad spline vertices or overlapping curves that will generate artifacts (as described in the Artifacts section). In those cases, its advised to use the Raster SDF format instead.

Raster SDF

This option uses an algorithm that renders the character into a texture and then creates the SDF from those pixels by trying to approximate the anti aliased curve. To get good results, it needs to render to a bigger texture (normally 8-32 times the size of the character) and then scale down to increase the accuracy of the approximation. That's why there is another parameter next to this to select the quality (normal=4 times the size while nicest = 32 times the size).


MSDF

This generates a Multi Channel Distance Field using the Geometry solver, which allows producing the 3 SDF fields needed to fill the RGB channels in a fraction of the time needed for a single  Raster SDF.

MSDFA

MSDF create high quality and sharp edges, but sometimes glow, shadow softness and other fading effects are preferable with more soft corners. This method (MSDFA) generates an MSDF field, but also generates and SDF and saves it in the Alpha Channel. The shader will use the MSDF wherever it needs sharp edges, and fallback to the SDF for glow and other soft effects.  

               


Memory Usage


Both SDF and Raster SDF formats generate an Alpha8 texture which only has an Alpha channel instead of the normal RGBA. This means that it uses 1/4 of your normal uncompressed RGBA texture size. Which makes this formats very mobile friendly where memory is a high concern.

MSDF creates an RGB24 texture which is 3 times the memory needed for the regular SDF. However, the main texture can be 1/4x smaller (e.g. 512x512 instead of 1024x1024) because of the extra accuracy of this format. So, at the end you can get even less memory usage with this format if following the quality guidelines described in the following sections.

MSDFA uses RGBA32. But it needs to be uncompressed. Therefore it uses quite a bit of memory. Nonetheless, the same as the MSDF, the main texture can be quite small while preserving the high quality, so if done properly, this is still very mobile friendly.


Also, take into account, that a single font texture can be use to render any character size (contrary to dynamic fonts that need to generate each character for each font size). So, even with MSDFA, this formats save memory in most common usages.


What format to use


In most cases fonts are rendered small in screen, except for Titles and texts that zoom in or out. Therefore the difference between MSDF and SDF fonts becomes less visible, so, most of the time SDF fonts are ok to use.

However, when texts are expected to show big in screen, or there are animations that scale them, then its preferable to use MSDF fonts. On the other size, choosing MSDFA instead of MSDF becomes more an artistic option depending on how important is the glow to be soft or precise.



In Summary


Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator