Sign in to follow this  
Kerndog73

When should fonts be rendered?

Recommended Posts

In my system I have a tool that renders fonts and creates an image file and an atlas file which my game engine then loads. Is this the right way to do things? Should I render the fonts at runtime instead?

Share this post


Link to post
Share on other sites

Doesn't the current Win10 window manager render GDI to texture anyway? I've read that in window mode directX is drawn on top of GDI for each window. That my be dated? Alpha could be a problem. Fullscreen without fiddling with the screen resolution should be easy. Do it like for GDI and then turn of borders. The current window manager is double buffered anyway. Otherwise any browser animation would look horrible. I dunno if this subpixel LCD optimization still shines though. Same with Apple or Linux after X. (Or amiga for what its worth)

Share this post


Link to post
Share on other sites

In my system I have a tool that renders fonts and creates an image file and an atlas file which my game engine then loads. Is this the right way to do things? Should I render the fonts at runtime instead?

Rendering sprite font is an optimization.

Usually it's cheaper to render a quad for a letter, than create it each time.

Creating off-line font texture usually decreases your game startup.

The next step of optimization - is to render all letters in one draw call (via instancing).

But it's better to have some GPU profiler before change in implementation.

Edited by Happy SDE

Share this post


Link to post
Share on other sites
@Happy SDE I thought my current approach would decrease start-up time. Isnt loading an image faster than rendering glyphs onto a texture?

Share this post


Link to post
Share on other sites

@Happy SDE I thought my current approach would decrease start-up time. Isnt loading an image faster than rendering glyphs onto a texture?

I got 4 different fonts in one 400 kb texture.

Pipeline creates it in 0.2 sec.

It takes so long because I use outlines (look at letters: there is a slight dark edge at each letter). It helps to see letters on bright surfaces.

One of optimizations: I need only 2 channels in font texture: color + alpha instead of 4 in RGBA.

The other benefit - I don't need to have GDI on user's machine (probably it is good if I would like to target consoles)

And after all, it takes only 0.009 millisec to render all of these letters in one draw call (look at "StatPass" number).

 

UPDATE: I just measured time of (load texture + load texture coordinates + create texture).

It takes only 1.8 milliseconds in games startup

So, 1.8 millisec is much better than 200 millisec :)

 

1OjsxWz.png

Edited by Happy SDE

Share this post


Link to post
Share on other sites
It also depends on your requirements. If you know all the glyphs that your game will need, then pre-createing textures is an option... But say you have a chat system in your game where players could type any of the millions of human language glyphs from around the globe, then pre-creating textures is not an option.

If you are pre-creating textures though, there's some expensive quality options available to you. Rendering glyphs at 4k resolution each, generating SDFs and downsampling them to say, 32px glyphs, is really expensive so you wouldn't do it at runtime, but that doesn't matter if you're doing it offline :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this