Visualization toolkits today and 3D user interfaces in the future require solutions for displaying 2D text decals in 3D space.
Current 3D text rendering libraries suffer from the following restrictions:
With the combination of well chosen mechanisms to display text in 3D, it is possible to achieve a high (though unhinted) text quality while rendering many thousands of glyphs per second on stock 3D hardware.
This text will show how and describes an implementation of a platform independent OpenGL library for 3D text.
Before displaying 3D text, the following decisions had to be made. These are dependent on the abilities of current stock hardware and the software-libraries available to render fonts.
Polygons or Textures
At first sight and when using hardware acceleration, polygonized fonts seem to be practical with the today’s throughput. But even the fastest consumer cards on the market are not able to render anti-aliased polygons at a reasonable speed, and because screen pixel resolution is currently somewhat limited, jagged edges are to be expected.
Even with full-screen anti-aliasing (FSAA), polygonized text quality is not acceptable, FSAA puts together a number of pixels to one (technically the complete scene will be rendered at a higher resolution and then scaled down), making low-contrast scenes look perfect, but high-contrast edges will result in a pulsating appearance when moved slowly.
There is another drawback using polygons: The high number of transformations used for the vertices and the high number of polygons needed to make rounded strokes appear without irregularities.
Current hardware is optimized for games, games are mostly texture-based including real-time alpha-blending support.
Font rendering library or pre-created font textures
Some text rendering libraries are using pre-rendered glyphs placed in a small texture to display the fonts. Obviously such applications are limited:
But on current stock hardware:
As a conclusion, using a font library for creating the 2D glyphs and rendering the text decals by using hardware-accelerated texture mapping is appropriate for a text-rendering library implemented to support current stock hardware.
GLTX uses textures and the font-library FreeType.
Initially GLTX should be small, optimized only for the best results in terms of quality and rendering speed. But while developing the library it turned out that all features needed were easy to implement in an orthogonal fashion.
arbitrary fonts
Using the FreeType library, GLTX is able to use arbitrary fonts and even supports most of the font formats available.
font hinting
Hinting 2D fonts for output in a 3D environment reduces output quality. Hinting unbalances the weight of the individual glyph strokes. Optional font hinting is supported, but not recommended.
texture and glyph creation on demand
GLTX realizes each glyph in a texture on its first use. So if an application uses only a subset of a font, only these glyphs have to be created.
anti-aliased glyphs
Beginning with version 2, the FreeType library supports rendering of anti-aliased glyphs, which turned out to be a big improvement of the output quality, surprisingly not interfering with FSAA. And if being rendered using a higher resolution, not decreasing the sharpness of the stroke edges.
ordered rendering
Texture state changes may be performance critical, and sorting for different textures is not that expensive, so optionally ordered rendering may be applied to render the glyphs in the order they appear in the different textures.
linear filtering
Linear filtering is strongly recommended, the quality of a nearest filtered texture output is obviously much worse.
mip-mapping
Even if mip-mapping sometimes avoids pulsating effects and visual artifacts, mip-mapping is not recommended for the following reasons:
fonts
mip-mapping
anisotropic filtering
Mip-Mapping implementation
This is a short overview about the (currently not recommended) mip-mapping implementation.
Two options are available for creating mip-map texture. One is to derive each mip-map level by using a predefined filtering algorithm from the original texture, the other is to create each texture by hand.
Mechanically scaling down character glyphs likely introduces blurry edges, so the current implementation creates each mip-map level glyph using the FreeType library.
The proper control of the individual mip-map textures allows the exact computation of the required gaps between the glyphs, and even allows font-hinting algorithms to adjust the look of the glyphs at different levels.
The drawbacks of the current mip-map implementation are:
GLTX is part of the paramatrix project.