Table of Contents

Class Sprite3DBatch

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

A batcher for sprite in the 3D world.

public class Sprite3DBatch : BatchBase<Sprite3DBatch.Sprite3DDrawInfo>, IDisposable, IComponent, IReferencable, ICollectorHolder
Inheritance
Sprite3DBatch
Implements
Inherited Members
Extension Methods

Constructors

Sprite3DBatch(GraphicsDevice, int, int)

Creates a new instance of Sprite3DBatch.

public Sprite3DBatch(GraphicsDevice device, int bufferElementCount = 1024, int batchCapacity = 64)

Parameters

device GraphicsDevice
bufferElementCount int

The maximum number element that can be batched in one time.

batchCapacity int

The batch capacity default to 64.

Methods

Begin(GraphicsContext, Matrix, SpriteSortMode, BlendStateDescription?, SamplerState, DepthStencilStateDescription?, RasterizerStateDescription?, EffectInstance, int)

Begins a 3D sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil, rasterizer state objects, plus a custom effect and a view-projection matrix. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.Default, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.

public void Begin(GraphicsContext graphicsContext, Matrix viewProjection, SpriteSortMode sortMode = SpriteSortMode.Deferred, BlendStateDescription? blendState = null, SamplerState samplerState = null, DepthStencilStateDescription? depthStencilState = null, RasterizerStateDescription? rasterizerState = null, EffectInstance effect = null, int stencilValue = 0)

Parameters

graphicsContext GraphicsContext

The graphics context to use.

viewProjection Matrix

The view-projection matrix to use for the batch session

sortMode SpriteSortMode

The sprite drawing order to use for the batch session

blendState BlendStateDescription?

The blending state to use for the batch session

samplerState SamplerState

The sampling state to use for the batch session

depthStencilState DepthStencilStateDescription?

The depth stencil state to use for the batch session

rasterizerState RasterizerStateDescription?

The rasterizer state to use for the batch session

effect EffectInstance

The effect to use for the batch session

stencilValue int

The value of the stencil buffer to take as reference for the batch session

Draw(Texture, ref Matrix, ref RectangleF, ref Vector2, ref Color4, ImageOrientation, SwizzleMode, float?)

Draw a 3D sprite (or add it to the draw list depending on the sortMode).

public void Draw(Texture texture, ref Matrix worldMatrix, ref RectangleF sourceRectangle, ref Vector2 elementSize, ref Color4 color, ImageOrientation imageOrientation = ImageOrientation.AsIs, SwizzleMode swizzle = SwizzleMode.None, float? depth = null)

Parameters

texture Texture

The texture to use during the draw

worldMatrix Matrix

The world matrix of the element

sourceRectangle RectangleF

The rectangle indicating the source region of the texture to use

elementSize Vector2

The size of the sprite in the object space

color Color4

The color to apply to the texture image.

imageOrientation ImageOrientation

The rotation to apply on the image uv

swizzle SwizzleMode

Swizzle mode indicating the swizzle use when sampling the texture in the shader

depth float?

The depth of the element. If null, it is calculated using world and view-projection matrix.

PrepareForRendering()

protected override void PrepareForRendering()

UpdateBufferValuesFromElementInfo(ref ElementInfo, nint, nint, int)

Update the mapped vertex and index buffer values using the provided element info.

protected override void UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo elementInfo, nint vertexPointer, nint indexPointer, int vexterStartOffset)

Parameters

elementInfo BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo

The structure containing the information about the element to draw.

vertexPointer nint

The pointer to the vertex array buffer to update.

indexPointer nint

The pointer to the index array buffer to update. This value is null if the index buffer used is static.

vexterStartOffset int

The offset in the vertex buffer where the vertex of the element starts