• Welcome to Dark Bit Factory & Gravity.
 

Distance field based font render

Started by Xetick, March 05, 2011

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Xetick

Finished my distance field font renderer and I though that others might be interested in this if they only knew just how useful it is.

If you start with a normal bitmap font text rendered it's very simple to convert it to a distance field font render system. I can highly recommended the angle font generator for a simple normal bitmap font rendererd. Then apply the bitsquad distance field tool to generate a distance field texture from it.

But part of the nice thing with a distance field is that you dont have to render simple monochrome fonts. Because the font contains the distance to the font outline you can have some fun with it. Like adding a outline, drop shadow or bluring the font in just a line of shader code or two. Valves original paper has the shader code for all of them.

An example of this is

In the original unscaled image the letters in that image is about 200 pixels height each and making them larger has only a small effect on the quality. The font used covers most ascii chars but fits in a 256x256 texture with only one component. The effect used is a drop shadow but adjusted to affect the inside of the characters.

Plane9 - Home of the Plane9 3d screensaver/music visualizer
Challenge Trophies Won:

va!n

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Xetick

Yes, thats the exact paper I link to ;)
Plane9 - Home of the Plane9 3d screensaver/music visualizer
Challenge Trophies Won:

Rbz

Challenge Trophies Won:

Rbz

yay! I've managed to implement this cool xna sample version.
Thanks Xetick for showing us this technique, it's very useful.

Use your cursor keys + A/Z to translate, F1/F2/F3 to change distance texture.

Requires a graphic card with PS 3.0.
Challenge Trophies Won:

Shockwave

Nice... Really elegant and cool!

I'l love to see a text writer from this technology with HUGE letters zooming into the screen or maybe even used to make an Outrun style road and scenery :)  I bet that would look as cool as hell.
Shockwave ^ Codigos
Challenge Trophies Won:

va!n

@rbz:
Really nice demonstration with a nice result @ 60/61 fps!
Btw, how to change the 'Scale' operator?

Would be nice to have the hotkeys as helppage under the info output ^^
Did i understand you right, that your version is based on XNA?
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Rbz

@va!n: You can use your numpad +/- to change scale.

QuoteDid i understand you right, that your version is based on XNA?
I've used my MSVC framework, I just borrowed it's .fx file which is in fact the core source code for this effect :)

@Shockwave: the possibilities are endless, Masagin anyone ;)
Challenge Trophies Won:

Xetick

@rbz
Thanks for the link. Haven't seen that link before. They do their own filtering if I understand correctly. I do wonder why because I haven't seen any problems on relying on the hardware to do it and even valves original paper just relies on the bilinear filtering hardware. But I guess the paper goes into details of why this is needed.

Nice demo. Seems like you did like me and went with valves approach.

Found something useful to write except the clocks I always seems to do with a text writer and did a quick test

'How I met your mother' does have it's highlights ;D
Plane9 - Home of the Plane9 3d screensaver/music visualizer
Challenge Trophies Won: