Table of Contents

Class InstancingExtensions

Namespace
Stride.CommunityToolkit.Rendering.Instancing
Assembly
Stride.CommunityToolkit.dll

Extension methods that wire up the engine features instanced rendering needs.

public static class InstancingExtensions
Inheritance
InstancingExtensions

Methods

AddInstancingBufferUpload(Game, params BufferedEntityInstancing[])

Registers BufferedEntityInstancing instances with the compositor so their GPU buffers are created and uploaded each frame.

public static InstancingBufferUploadRenderer AddInstancingBufferUpload(this Game game, params BufferedEntityInstancing[] instancings)

Parameters

game Game

The game whose compositor to modify.

instancings BufferedEntityInstancing[]

The buffered instancings to manage.

Returns

InstancingBufferUploadRenderer

The renderer doing the work, so further targets can be added to it later.

Remarks

The renderer is inserted before the one that draws the scene, so uploads are recorded ahead of the draw calls that read them. Calling this repeatedly reuses the existing renderer rather than adding another. This does not enable instancing itself - call AddInstancingSupport(Game) too.

AddInstancingSupport(Game)

Enables instanced rendering by adding an InstancingRenderFeature to the compositor's MeshRenderFeature.

public static bool AddInstancingSupport(this Game game)

Parameters

game Game

The game whose compositor to modify.

Returns

bool

true if it was added, false if it was already there.

Remarks

Code-only projects need this and nothing warns when it is missing: the compositor built by GraphicsCompositorHelper.CreateDefault wires up transform, skinning, material, shadow-caster and lighting, but not instancing. Without it every instanced master renders as a single model at its own transform and the instances are invisible. Calling it twice is safe.

Exceptions

InvalidOperationException

The compositor has no MeshRenderFeature.