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(IGame, bool, IComputeColor?, bool)

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

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

Parameters

game IGame

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 post-processing, in the compositor's UI stage, so colours are not tone-mapped; in the scene, auto exposure can draw a white shape about half grey. Right for a HUD, wrong for a decal. Nothing is depth-tested there. Needs the toolkit's UI stage (AddUIStage or AddCleanUIStage, added by SetupBase3D and AddGraphicsCompositor); without it the batch draws in the 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. Batches in the same stage draw in the order they were added, the later one on top. 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(IGame, 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 IGame game, ShapeBatch batch)

Parameters

game IGame

The game the batch was added to.

batch ShapeBatch

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