Table of Contents

Class ShapeBatchExtensions

Namespace
Stride.CommunityToolkit.Shapes
Assembly
Stride.CommunityToolkit.Shapes.dll

Wires ShapeBatch rendering into a game's graphics compositor.

public static class ShapeBatchExtensions
Inheritance
ShapeBatchExtensions

Methods

AddShapeBatch(Game, bool, IComputeColor?, bool)

Registers the shape renderer and returns the batch to submit shapes to.

public static ShapeBatch AddShapeBatch(this Game game, bool depthTest = false, IComputeColor? fill = null, bool afterPostEffects = false)

Parameters

game Game

The game whose compositor to modify.

depthTest bool

Whether scene geometry can occlude these shapes. Leave false for gizmos, 2D scenes and anything that should stay visible through walls; pass true for decals and ground markers that belong in the scene.

fill IComputeColor

A fill source for a textured batch - see FillSource - or null for plain fills. FillWith(Texture, Vector2?, Vector2?, TextureAddressMode) installs one later for the common case.

afterPostEffects bool

Draw the batch after the post-processing chain, in the compositor's UI stage, where the text renderers draw: a colour comes out as given. In the scene, a shape goes through the tone mapper with everything else, and under auto exposure a white shape lands at whatever grey the frame's brightness leaves it - about half, next to text that is truly white. That is right for a decal on the ground and wrong for a HUD. Nothing is depth-tested there; the compositor must have the toolkit's UI stage (AddUIStage or AddCleanUIStage, which SetupBase3D and AddGraphicsCompositor both do), else the batch falls back to the scene's transparent stage.

Returns

ShapeBatch

The batch: submit shapes to it every frame from your update logic.

Remarks

Shapes render in the compositor's "Transparent" stage, alpha-blended in submission order, before UI and debug text - or, with afterPostEffects, in the UI stage after the post effects. Call after the graphics compositor exists (from the Start callback). Calling this more than once adds another independent batch, which is how you get depth-tested and overlay shapes in the same scene; the first batch registers as the service that ShapeComponent draws through. A scene that never calls this still draws its components: the processor registers a depth-tested batch of its own the first time it needs one.

Exceptions

InvalidOperationException

The compositor has no "Transparent" render stage.

RemoveShapeBatch(Game, ShapeBatch)

Takes a batch out of rendering. Its shapes stop drawing from the next frame; the batch itself can be added again later.

public static void RemoveShapeBatch(this Game game, ShapeBatch batch)

Parameters

game Game

The game the batch was added to.

batch ShapeBatch

The batch AddShapeBatch(Game, bool, IComputeColor?, bool) returned.