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(IGame, params BufferedEntityInstancing[])
Registers BufferedEntityInstancing instances with the compositor so their GPU buffers are created and uploaded each frame.
public static InstancingBufferUploadRenderer AddInstancingBufferUpload(this IGame game, params BufferedEntityInstancing[] instancings)
Parameters
gameIGameThe game whose compositor to modify.
instancingsBufferedEntityInstancing[]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. It enables instancing as well, so AddInstancingSupport(IGame) need not be called first.
AddInstancingSupport(IGame)
Enables instanced rendering by adding an InstancingRenderFeature to the compositor's MeshRenderFeature.
public static bool AddInstancingSupport(this IGame game)
Parameters
gameIGameThe game whose compositor to modify.
Returns
Remarks
Code-only projects need this: 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; the run loop logs a warning when it finds a master in that state. Calling it twice is
safe. UseInstancing<T>(T) on the scene setup and AddInstancingBufferUpload(IGame, params BufferedEntityInstancing[])
both do this for you.
Exceptions
- InvalidOperationException
The compositor has no MeshRenderFeature.
UseInstancing<T>(T)
Asks the scene setup for instanced rendering: the InstancingRenderFeature is in the
compositor from the first frame, the way UseBepu() gives the scene its physics.
public static T UseInstancing<T>(this T setup) where T : SceneSetup
Parameters
setupTThe setup.
Returns
- T
The same setup.
Type Parameters
TThe setup type, so the call chains.