TextPass
TextPass collects all text entities in the scene and renders them as textured quads into scene_color using pre-rasterized font atlases. Text is rendered in screen space, after geometry and skybox, before the widget layer.
Render Graph Role
| Attribute | Value |
|---|---|
| Group | UI |
| Reads | - |
| Read-Write | scene_color |
| Cullable | Yes |
Text Entities
Text is added to the scene as a Text entity:
auto* label = add_entity<Text>("FPSLabel");
label->content = "Hello, Astra!";
label->font_id = "roboto";
label->position = glm::vec2(16.0f, 16.0f);
label->scale = 1.0f;
label->color = glm::vec4(1.0f);content may be updated every frame - the pass re-builds the quad buffer each frame from the current string value.
Batching
TextPass groups entities by font_id. For each unique font, it:
- Resolves the font atlas texture from
ResourceManager. - Builds an interleaved vertex buffer of position and UV quads - one quad per glyph.
- Issues a single instanced draw call per font atlas.
Switching between fonts incurs one texture bind, not one draw call per character.
Coordinate System
Text positions are in window pixel space with the origin at the top-left corner. scale is a uniform multiplier applied on top of the atlas base size.
Transparency
Text quads are rendered with alpha blending enabled (src_alpha / one_minus_src_alpha). The pass enables blending only for its draw calls and restores the previous state after.
Font Registration
Fonts must be registered and uploaded before the scene starts:
res->register_font(FontDescriptor::create("roboto", "fonts/Roboto-Regular.ttf"_engine, 512, 48));
res->load_from_descriptors<FontDescriptor>(RendererBackend::OpenGL);See Font for full registration details.