What is the new feature?
It's a new way to generate text atlases. So far we have been generating glyphs on the CPU. At lower generation size, there were some visual quality problems. At higher generation size the cost was usually prohibitively expensive in terms of processing power. Furthermore that approach was stopping us from implementing another important feature, which we will implement in the following releases - text outlines used for stroked text. The new experimental solution does most of the work on the GPU and that gives us the ability to generate even higher resolution text atlases without increase in CPU usage. This allows users to choose desired generation to best suit their use case and balance between text visual quality required and memory used.
Notice/Limitations:
The feature requires that the graphics API/hardware used supports 2 essential features specified in the renoir::RendererCaps
structure filled in the RendererBackend::FillCaps
method. The 2 required features are:
renoir::RendererCaps::CanOutputDepthInPixelShader
renoir::RendererCaps::SupportsTwoSidedStencilOperations
If either of those capabilities are not supported, SDF rendering is done on the CPU as a fallback. The stock backends for D3D9 and GLES2 do not support these so they are an example for CPU SDF rendering.
Comparison with the old algorithm
We have already mentioned that the new algorithm is very scalable in regard to glyph generation size as it relates to CPU usage whereas the old one wasn't. It also allows us to implement nice-looking outlines - again something that the old algorithm wasn't capable of. A picture says a thousand words, so...
Before @ default(52px) generation size:
SDFGPU @ default(52px) generation size:
Outlines @ default(52px) generation size with 8px spread:
How to use it?
Atlas with different generation size:
SDFGPU atlas @ default(52px) generation size:
SDFGPU atlas @ 96px generation size:
SDFGPU atlas @ 128px generation size:
Text quality with different generation size:
SDFGPU text quality @ default(52px) generation size:
SDFGPU text quality @ 96px generation size:
SDFGPU text quality @ 128px generation size:
Atlas with different spread:
SDFGPU atlas @ 128px generation size with 2px spread:
SDFGPU atlas @ 128px generation size with 8px spread:
SDFGPU atlas @ 128px generation size with 12px spread:
Outline width with different spread:
Outline width 52px - capped to maxOutlineWidth @ 128px generation size with 2px spread:
Outline width 52px - capped to maxOutlineWidth @ 128px generation size with 8px spread:
Outline width 52px - capped to maxOutlineWidth @ 128px generation size with 12px spread: