Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::IShaderInstancing Class Referenceabstract

Abstract base class for GPU instancing logic in Skylicht-Engine. More...

#include <Material/Shader/Instancing/IShaderInstancing.h>

Inheritance diagram for Skylicht::IShaderInstancing:
Skylicht::C2TCoordColorInstancing Skylicht::CSkinTBNSGInstancing Skylicht::CStandardColorInstancing Skylicht::CStandardSGInstancing Skylicht::CTBNSGInstancing

Public Member Functions

 IShaderInstancing ()
 Constructor. Initializes descriptors to null.
virtual ~IShaderInstancing ()
 Destructor.
virtual void setupDescriptorForRenderLighting (const char *name)
 Set up vertex descriptor for instanced rendering with lighting data. Adds necessary attributes for color, UV scaling, and world matrix.
virtual bool isSupport (IMeshBuffer *mb)
 Check if instancing is supported for the given mesh buffer. Compares vertex descriptors to base and instanced formats.
virtual bool isSupport (IMesh *mesh)
 Check if instancing is supported for the given mesh. Compares vertex descriptors for all mesh buffers.
virtual IMeshBuffer * createLinkMeshBuffer (IMeshBuffer *mb)
 Create a mesh buffer that links to the vertex and index buffers of another mesh buffer. Used for instanced rendering.
virtual IVertexBuffer * createInstancingVertexBuffer ()=0
 Create a vertex buffer for instancing data (must be implemented by subclasses).
virtual IMeshBuffer * createMeshBuffer (video::E_INDEX_TYPE type)=0
 Create a mesh buffer for a specific index type (must be implemented by subclasses).
virtual bool applyInstancing (IMeshBuffer *meshbuffer, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
 Apply instancing setup to a mesh buffer, binding instancing and transform buffers.
virtual bool applyInstancingForRenderLighting (IMeshBuffer *meshbuffer, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
 Apply instancing setup for render lighting to a mesh buffer, binding buffers and using lighting descriptor.
virtual bool removeInstancing (IMeshBuffer *meshbuffer)
 Remove instancing buffers from a mesh buffer, restoring the base descriptor.
virtual bool applyInstancing (IMesh *mesh, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
 Apply instancing setup to all mesh buffers in a mesh, binding instancing and transform buffers.
virtual bool applyInstancingForRenderLighting (IMesh *mesh, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
 Apply instancing setup for render lighting to all mesh buffers in a mesh.
virtual bool removeInstancing (IMesh *mesh)
 Remove instancing buffers from all mesh buffers in a mesh, restoring the base descriptor.
virtual void batchIntancing (IVertexBuffer *vtxBuffer, CMaterial **materials, CEntity **entities, int count)=0
 Batch update instancing vertex buffer with transform and material data for multiple entities (must be implemented by subclasses).
video::IVertexDescriptorgetBaseVertexDescriptor ()
 Get the base vertex descriptor used for original mesh format.
video::IVertexDescriptorgetInstancingVertexDescriptor ()
 Get the instancing vertex descriptor used for instanced rendering format.

Static Public Member Functions

static IVertexBuffer * createTransformVertexBuffer ()
 Create a vertex buffer for transform matrices (static method).
static IVertexBuffer * createIndirectLightingVertexBuffer ()
 Create a vertex buffer for indirect lighting data (static method).
static void batchTransformAndLighting (IVertexBuffer *tBuffer, IVertexBuffer *lBuffer, CEntity **entities, int count)
 Batch update transform and lighting vertex buffers for multiple entities (static method).
static void batchTransform (IVertexBuffer *tBuffer, CEntity **entities, int count)
 Batch update transform vertex buffer for multiple entities (static method).

Protected Attributes

video::IVertexDescriptorm_baseVtxDescriptor
 The base vertex descriptor(original mesh format).
video::IVertexDescriptorm_vtxDescriptor
 Vertex descriptor for instanced rendering.
video::IVertexDescriptorm_vtxDescriptorForRenderLighting
 Vertex descriptor for instanced rendering with lighting data.

Detailed Description

Abstract base class for GPU instancing logic in Skylicht-Engine.

Provides an interface for describing how vertex buffers and mesh buffers should be configured for hardware instancing, including batching transforms and lighting, descriptor setup, compatibility checks, and linking buffers.

Member Function Documentation

◆ applyInstancing() [1/2]

virtual bool Skylicht::IShaderInstancing::applyInstancing ( IMesh * mesh,
IVertexBuffer * instancingBuffer,
IVertexBuffer * transformBuffer )
virtual

Apply instancing setup to all mesh buffers in a mesh, binding instancing and transform buffers.

Parameters
meshTarget mesh.
instancingBufferInstancing vertex buffer.
transformBufferTransform vertex buffer.
Returns
True if successful.

◆ applyInstancing() [2/2]

virtual bool Skylicht::IShaderInstancing::applyInstancing ( IMeshBuffer * meshbuffer,
IVertexBuffer * instancingBuffer,
IVertexBuffer * transformBuffer )
virtual

Apply instancing setup to a mesh buffer, binding instancing and transform buffers.

Parameters
meshbufferTarget mesh buffer.
instancingBufferInstancing vertex buffer.
transformBufferTransform vertex buffer.
Returns
True if successful.

◆ applyInstancingForRenderLighting() [1/2]

virtual bool Skylicht::IShaderInstancing::applyInstancingForRenderLighting ( IMesh * mesh,
IVertexBuffer * instancingBuffer,
IVertexBuffer * transformBuffer )
virtual

Apply instancing setup for render lighting to all mesh buffers in a mesh.

Parameters
meshTarget mesh.
instancingBufferInstancing vertex buffer.
transformBufferTransform vertex buffer.
Returns
True if successful.

◆ applyInstancingForRenderLighting() [2/2]

virtual bool Skylicht::IShaderInstancing::applyInstancingForRenderLighting ( IMeshBuffer * meshbuffer,
IVertexBuffer * instancingBuffer,
IVertexBuffer * transformBuffer )
virtual

Apply instancing setup for render lighting to a mesh buffer, binding buffers and using lighting descriptor.

Parameters
meshbufferTarget mesh buffer.
instancingBufferInstancing vertex buffer.
transformBufferTransform vertex buffer.
Returns
True if successful.

◆ batchIntancing()

virtual void Skylicht::IShaderInstancing::batchIntancing ( IVertexBuffer * vtxBuffer,
CMaterial ** materials,
CEntity ** entities,
int count )
pure virtual

Batch update instancing vertex buffer with transform and material data for multiple entities (must be implemented by subclasses).

Parameters
vtxBufferInstancing vertex buffer to fill.
materialsArray of materials per entity.
entitiesArray of entities.
countNumber of instances.

Implemented in Skylicht::C2TCoordColorInstancing, Skylicht::CSkinTBNSGInstancing, Skylicht::CStandardColorInstancing, Skylicht::CStandardSGInstancing, and Skylicht::CTBNSGInstancing.

◆ batchTransform()

void Skylicht::IShaderInstancing::batchTransform ( IVertexBuffer * tBuffer,
CEntity ** entities,
int count )
static

Batch update transform vertex buffer for multiple entities (static method).

Parameters
tBufferTransform vertex buffer.
entitiesArray of entities.
countNumber of instances.

◆ batchTransformAndLighting()

void Skylicht::IShaderInstancing::batchTransformAndLighting ( IVertexBuffer * tBuffer,
IVertexBuffer * lBuffer,
CEntity ** entities,
int count )
static

Batch update transform and lighting vertex buffers for multiple entities (static method).

Parameters
tBufferTransform vertex buffer.
lBufferIndirect lighting vertex buffer.
entitiesArray of entities.
countNumber of instances.

◆ createIndirectLightingVertexBuffer()

IVertexBuffer * Skylicht::IShaderInstancing::createIndirectLightingVertexBuffer ( )
static

Create a vertex buffer for indirect lighting data (static method).

Returns
Pointer to indirect lighting vertex buffer.

◆ createInstancingVertexBuffer()

virtual IVertexBuffer * Skylicht::IShaderInstancing::createInstancingVertexBuffer ( )
pure virtual

Create a vertex buffer for instancing data (must be implemented by subclasses).

Returns
Pointer to newly created instancing vertex buffer.

Implemented in Skylicht::C2TCoordColorInstancing, Skylicht::CSkinTBNSGInstancing, Skylicht::CStandardColorInstancing, Skylicht::CStandardSGInstancing, and Skylicht::CTBNSGInstancing.

◆ createLinkMeshBuffer()

virtual IMeshBuffer * Skylicht::IShaderInstancing::createLinkMeshBuffer ( IMeshBuffer * mb)
virtual

Create a mesh buffer that links to the vertex and index buffers of another mesh buffer. Used for instanced rendering.

Parameters
mbSource mesh buffer to link.
Returns
Pointer to new linked mesh buffer.

◆ createMeshBuffer()

virtual IMeshBuffer * Skylicht::IShaderInstancing::createMeshBuffer ( video::E_INDEX_TYPE type)
pure virtual

Create a mesh buffer for a specific index type (must be implemented by subclasses).

Parameters
typeIndex buffer type.
Returns
Pointer to newly created mesh buffer.

Implemented in Skylicht::C2TCoordColorInstancing, Skylicht::CSkinTBNSGInstancing, Skylicht::CStandardColorInstancing, Skylicht::CStandardSGInstancing, and Skylicht::CTBNSGInstancing.

◆ createTransformVertexBuffer()

IVertexBuffer * Skylicht::IShaderInstancing::createTransformVertexBuffer ( )
static

Create a vertex buffer for transform matrices (static method).

Returns
Pointer to transform vertex buffer.

◆ getBaseVertexDescriptor()

video::IVertexDescriptor * Skylicht::IShaderInstancing::getBaseVertexDescriptor ( )
inline

Get the base vertex descriptor used for original mesh format.

Returns
Pointer to base vertex descriptor.

◆ getInstancingVertexDescriptor()

video::IVertexDescriptor * Skylicht::IShaderInstancing::getInstancingVertexDescriptor ( )
inline

Get the instancing vertex descriptor used for instanced rendering format.

Returns
Pointer to instancing vertex descriptor.

◆ isSupport() [1/2]

virtual bool Skylicht::IShaderInstancing::isSupport ( IMesh * mesh)
virtual

Check if instancing is supported for the given mesh. Compares vertex descriptors for all mesh buffers.

Parameters
meshMesh to check.
Returns
True if supported, false otherwise.

◆ isSupport() [2/2]

virtual bool Skylicht::IShaderInstancing::isSupport ( IMeshBuffer * mb)
virtual

Check if instancing is supported for the given mesh buffer. Compares vertex descriptors to base and instanced formats.

Parameters
mbMesh buffer to check.
Returns
True if supported, false otherwise.

◆ removeInstancing() [1/2]

virtual bool Skylicht::IShaderInstancing::removeInstancing ( IMesh * mesh)
virtual

Remove instancing buffers from all mesh buffers in a mesh, restoring the base descriptor.

Parameters
meshTarget mesh.
Returns
True if successful.

◆ removeInstancing() [2/2]

virtual bool Skylicht::IShaderInstancing::removeInstancing ( IMeshBuffer * meshbuffer)
virtual

Remove instancing buffers from a mesh buffer, restoring the base descriptor.

Parameters
meshbufferTarget mesh buffer.
Returns
True if successful.

◆ setupDescriptorForRenderLighting()

virtual void Skylicht::IShaderInstancing::setupDescriptorForRenderLighting ( const char * name)
virtual

Set up vertex descriptor for instanced rendering with lighting data. Adds necessary attributes for color, UV scaling, and world matrix.

Parameters
nameName of the vertex descriptor.

The documentation for this class was generated from the following file: