Class WorldTextRenderer
- Namespace
- Stride.CommunityToolkit.Renderers
- Assembly
- Stride.CommunityToolkit.dll
Draws every WorldTextComponent as text standing in the 3D scene rather than over it.
public class WorldTextRenderer : SceneRendererBase, IComponent, IReferencable, ICollectorHolder, ISceneRenderer, IRenderCollector, IGraphicsRenderer, IGraphicsRendererBase, IGraphicsRendererCore, IDisposable
- Inheritance
-
WorldTextRenderer
- Implements
- Inherited Members
Remarks
Add one to the graphics compositor - game.AddSceneRenderer(new WorldTextRenderer()) - and any
entity carrying a WorldTextComponent is drawn at its transform, scaled by perspective
and, by default, hidden by geometry in front of it.
How it works, and what it costs. SpriteBatch can be given explicit view and
projection matrices, which turns its 2D quads into geometry positioned in world space. Folding each
text's world matrix into the view matrix places and orients it, and the depth state decides whether
the scene occludes it. The catch is that the matrices belong to the batch rather than the draw call,
so each text needs its own Begin/End pair and therefore its own draw call. That is
fine for the tens of labels this is meant for - axis names, debug markers, a sign over a spawn point
- and would not be fine for thousands. Batching them would mean rendering each distinct string to a
texture and drawing those through Sprite3DBatch, which takes a world matrix per
sprite; worth doing only if the counts ever justify the cache it needs.
Methods
Destroy()
protected override void Destroy()
DrawCore(RenderContext, RenderDrawContext)
protected override void DrawCore(RenderContext context, RenderDrawContext drawContext)
Parameters
contextRenderContextdrawContextRenderDrawContext
InitializeCore()
protected override void InitializeCore()