Skylicht Engine
Loading...
Searching...
No Matches
IShaderInstancing.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "Entity/CEntity.h"
28#include "VertexInstancingType.h"
29#include "Transform/CWorldTransformData.h"
30#include "IndirectLighting/CIndirectLightingData.h"
31
32namespace Skylicht
33{
34 class CMaterial;
35
44 class SKYLICHT_API IShaderInstancing
45 {
46 protected:
49
52
55
56 public:
61
66
72 virtual void setupDescriptorForRenderLighting(const char* name);
73
80 virtual bool isSupport(IMeshBuffer* mb);
81
88 virtual bool isSupport(IMesh* mesh);
89
96 virtual IMeshBuffer* createLinkMeshBuffer(IMeshBuffer* mb);
97
102 virtual IVertexBuffer* createInstancingVertexBuffer() = 0;
103
109 virtual IMeshBuffer* createMeshBuffer(video::E_INDEX_TYPE type) = 0;
110
115 static IVertexBuffer* createTransformVertexBuffer();
116
121 static IVertexBuffer* createIndirectLightingVertexBuffer();
122
130 virtual bool applyInstancing(IMeshBuffer* meshbuffer, IVertexBuffer* instancingBuffer, IVertexBuffer* transformBuffer);
131
139 virtual bool applyInstancingForRenderLighting(IMeshBuffer* meshbuffer, IVertexBuffer* instancingBuffer, IVertexBuffer* transformBuffer);
140
146 virtual bool removeInstancing(IMeshBuffer* meshbuffer);
147
155 virtual bool applyInstancing(IMesh* mesh, IVertexBuffer* instancingBuffer, IVertexBuffer* transformBuffer);
156
164 virtual bool applyInstancingForRenderLighting(IMesh* mesh, IVertexBuffer* instancingBuffer, IVertexBuffer* transformBuffer);
165
171 virtual bool removeInstancing(IMesh* mesh);
172
180 virtual void batchIntancing(IVertexBuffer* vtxBuffer,
181 CMaterial** materials,
182 CEntity** entities,
183 int count) = 0;
184
193 IVertexBuffer* tBuffer,
194 IVertexBuffer* lBuffer,
195 CEntity** entities,
196 int count);
197
204 static void batchTransform(
205 IVertexBuffer* tBuffer,
206 CEntity** entities,
207 int count);
208
217
226 };
227}
This is the object class that describes an entity.
Definition CEntity.h:58
The object class describes material information such as which shader it's associated with,...
Definition CMaterial.h:84
virtual bool applyInstancing(IMeshBuffer *meshbuffer, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
Apply instancing setup to a mesh buffer, binding instancing and transform buffers.
video::IVertexDescriptor * m_vtxDescriptor
Vertex descriptor for instanced rendering.
Definition IShaderInstancing.h:51
static void batchTransformAndLighting(IVertexBuffer *tBuffer, IVertexBuffer *lBuffer, CEntity **entities, int count)
Batch update transform and lighting vertex buffers for multiple entities (static method).
virtual IMeshBuffer * createLinkMeshBuffer(IMeshBuffer *mb)
Create a mesh buffer that links to the vertex and index buffers of another mesh buffer....
static IVertexBuffer * createTransformVertexBuffer()
Create a vertex buffer for transform matrices (static method).
virtual bool applyInstancingForRenderLighting(IMesh *mesh, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
Apply instancing setup for render lighting to all mesh buffers in a mesh.
video::IVertexDescriptor * getBaseVertexDescriptor()
Get the base vertex descriptor used for original mesh format.
Definition IShaderInstancing.h:213
static void batchTransform(IVertexBuffer *tBuffer, CEntity **entities, int count)
Batch update transform vertex buffer for multiple entities (static method).
virtual IVertexBuffer * createInstancingVertexBuffer()=0
Create a vertex buffer for instancing data (must be implemented by subclasses).
virtual bool isSupport(IMeshBuffer *mb)
Check if instancing is supported for the given mesh buffer. Compares vertex descriptors to base and i...
virtual bool removeInstancing(IMeshBuffer *meshbuffer)
Remove instancing buffers from a mesh buffer, 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...
virtual bool isSupport(IMesh *mesh)
Check if instancing is supported for the given mesh. Compares vertex descriptors for all mesh 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 descr...
virtual void setupDescriptorForRenderLighting(const char *name)
Set up vertex descriptor for instanced rendering with lighting data. Adds necessary attributes for co...
virtual bool removeInstancing(IMesh *mesh)
Remove instancing buffers from all mesh buffers in a mesh, restoring the base descriptor.
video::IVertexDescriptor * m_vtxDescriptorForRenderLighting
Vertex descriptor for instanced rendering with lighting data.
Definition IShaderInstancing.h:54
video::IVertexDescriptor * getInstancingVertexDescriptor()
Get the instancing vertex descriptor used for instanced rendering format.
Definition IShaderInstancing.h:222
static IVertexBuffer * createIndirectLightingVertexBuffer()
Create a vertex buffer for indirect lighting data (static method).
virtual IMeshBuffer * createMeshBuffer(video::E_INDEX_TYPE type)=0
Create a mesh buffer for a specific index type (must be implemented by subclasses).
virtual ~IShaderInstancing()
Destructor.
video::IVertexDescriptor * m_baseVtxDescriptor
The base vertex descriptor(original mesh format).
Definition IShaderInstancing.h:48
IShaderInstancing()
Constructor. Initializes descriptors to null.
virtual bool applyInstancing(IMesh *mesh, IVertexBuffer *instancingBuffer, IVertexBuffer *transformBuffer)
Apply instancing setup to all mesh buffers in a mesh, binding instancing and transform buffers.
Definition IVertexDescriptor.h:154
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29