Skip to main content

Function: createTextRenderable()

createTextRenderable(renderContext, fontAtlas, category): TextRenderables

Defined in: text/rendering/create-text-renderable.ts:78

Builds the pair of Renderables a FontAtlas's glyphs are drawn with: the shared sprite quad geometry, paired with the MSDF fill/effects fragment shaders and this atlas's texture/metrics uniforms.

Glyph rendering is split into two ordered passes - fill and outline/shadow ("effects") - rather than the single combined draw a SpriteEcsComponent uses, so that an outline/shadow can safely reach past a same-word neighboring glyph (even merge with that neighbor's own outline) without ever painting over that neighbor's own fill: every glyph's effects in a text entity are pushed before every glyph's fill (see pushTextRenderCommands), and effectsRenderable's draw call always completes before fillRenderable's, so fill always ends up on top regardless of how far an effect reaches. See documentation-site/docs/docs/text/text-effects.md for the full rationale and the atlas-encoding budget that still bounds how far an outline can reach.

Callers should create (and cache) at most one pair of these per (FontAtlas, category) pair - every TextMeshEcsComponent sharing a Renderable batches into a single instanced draw call, exactly like sprites sharing a texture do today. createTextShapingEcsSystem does this caching automatically.

Parameters​

renderContext​

RenderContext

The render context to build the renderables with.

fontAtlas​

FontAtlas

The loaded font atlas to draw glyphs from.

category​

number

The render category to assign both renderables (see TEXT_RENDER_CATEGORY).

Returns​

TextRenderables

The renderables, ready to be shared by every TextMeshEcsComponent using fontAtlas with this category.