Revisiting Text

As I write this post I’m in the process of merging both desktop and mobile OpenGL renderers into a unified one that supports both platforms. Although this is still incomplete, I wanted to share some of its benefits and side effects in the meantime.

A while back I talked about how to render dynamic text in 3D using Signed Distance Fields (SDFs). It turns out that approach is way too expensive for mobile and it doesn’t really provide too much of an improvement in smaller screens. So, no SDF support means that we need to provide two different textures for each bitmap font (with and without SDF). If SDF is supported in the current platform (i.e. desktop), the SDF texture is used for rendering. Otherwise, we use the standard bitmap font without any fancy processing.

Current implementation provides Text and Font classes, but it relies on client code to specify which texture to use. At first it looks like a versatile feature, but it ends up being very cumbersome.

Instead, the changes I’m making make sure this decision is left to the engine. Then, if current platform supports SDF, it will construct Text objects with the appropriated texture and shader program automatically.

In practice, these changes lead to a cleaner code on the client side, which now is unaware of whether or not SDF is being used. Both textures still have to be provided, of course, yet only one of them will be actually used when the program runs.

That’s it for now, but I’m planning on sharing much more about the new renderer soon. Stay tuned.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s