Followers 0

# Distance field font artifacts

## 8 posts in this topic

Hello,

I'm wondering how Valve got their distance field font looking so good. I tried generating my font with other tools, my tool and photoshop but the results are almost never as perfect as they are in Valves paper.

So my question is: must you fine tune the alpha threshold and is fattening the font characters "correct" in order to get them to draw nicely?

The distance field font texture is 256x128 and every letter is around 20x20 pixels.

Here are two images:

- the top one has thinner font with more artiafacts

- the bottom one has fatter font with less artifacts

http://i.imgur.com/ACVpfnX.png

http://i.imgur.com/OWmk1Zg.png

0

##### Share on other sites

I think that in Valve's paper http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf they're just using a higher resolution than you. In figure 4 (the image with significant magnification), they're using a 256x256 "No Trespassing" source image, which judging by the layout of the source image in figure 2 would amount to 40-50 pixel height per character.

1

##### Share on other sites

Thanks for the replies, makes sense.

0

##### Share on other sites

Off topic tip: Instead of an alpha threshold, you could try a steep gradient outside the threshold, which will give nice antialiasing :)

1

##### Share on other sites

Yup done that, looks very nice :D

0

##### Share on other sites

Off topic tip: Instead of an alpha threshold, you could try a steep gradient outside the threshold, which will give nice antialiasing

Could you possibly give some more detail how this work? How to make "steep gradient" to blend between DF and base font texture?

0

##### Share on other sites

It's in that valve paper as well, the paragraph about antialiasing. The corresponding code is the one in the SOFT_EDGES if-clause, basically a smoothstep using the distance value and some range. Alternatively - also mentioned in the paragraph - on SM 3.0 one can use hardware gradients (ddx, ddy) so one wouldn't need to adjust the range for different sizes (viewing distances).

1

##### Share on other sites

Thanks, but i need more help to understand this?

1. This Valve article is only valid for alpha tested "objects"?

2.

alpha = smoothstep( edge_min, edge_max, alphaDF );


In what ranges these first two parameters should be in context of rendering 2d fonts?

3. I don't understand ddx/y function, what parameters is it expecting and how should i replace smoothstep with them?

Thank you for your time and understanding.

0

## Create an account

Register a new account