Skylicht Engine
Loading...
Searching...
No Matches
SMeshInstancing.h
1/*
2!@
3MIT License
4
5Copyright (c) 2024 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 "irrlicht.h"
28using namespace irr::scene;
29
30#include "Material/CMaterial.h"
31#include "Material/Shader/Instancing/IShaderInstancing.h"
32
33namespace Skylicht
34{
36
37 // Use in CMeshRendererInstancing
38 struct SMeshInstancing
39 {
40 // base source mesh buffers
41 core::array<IMeshBuffer*> MeshBuffers;
42
43 // base source materials
45
46 // shader instancing for batching
47 core::array<IShaderInstancing*> InstancingShader;
48
49 // shader instancing handle (use on SkinnedInstancing)
50 IShaderInstancing* HandleShader;
51
52 // vertex buffer, that batch materials (color, uv, sg, bone..)
53 core::array<IVertexBuffer*> MaterialBuffer;
54
55 // vertex buffer, that batch transform
56 IVertexBuffer* TransformBuffer;
57
58 // vertex buffer, that bake SH
59 IVertexBuffer* IndirectLightingBuffer;
60
61 // mesh instancing, that will render
62 IMesh* InstancingMesh;
63
64 // list buffers in InstancingMesh
65 core::array<IMeshBuffer*> RenderMeshBuffers;
66
67 // list buffers in IndirectLightingMesh (CMesh property)
68 core::array<IMeshBuffer*> RenderLightMeshBuffers;
69
70 // the group, that have many instances will be render
71 SMeshInstancingGroup* InstancingGroup;
72
73 // the base mesh vertex type
74 video::E_VERTEX_TYPE BaseVertexType;
75
76 // That tell us that, transform and lighting buffer is shared with another Mesh
77 bool UseShareTransformBuffer;
78 bool UseShareMaterialsBuffer;
79
80 int* ShareDataTransform;
81 int* ShareDataMaterials;
82
83 SMeshInstancing(video::E_VERTEX_TYPE vtxType)
84 {
85 HandleShader = NULL;
86 InstancingMesh = NULL;
87 TransformBuffer = NULL;
88 IndirectLightingBuffer = NULL;
89 InstancingGroup = NULL;
90 UseShareTransformBuffer = false;
91 UseShareMaterialsBuffer = false;
92 ShareDataTransform = NULL;
93 ShareDataMaterials = NULL;
94 BaseVertexType = vtxType;
95 }
96
97 ~SMeshInstancing()
98 {
99 if (HandleShader)
100 delete HandleShader;
101 }
102 };
103}
Abstract base class for GPU instancing logic in Skylicht-Engine.
Definition IShaderInstancing.h:45
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
Class which holds the geometry of an object.
Definition IMesh.h:24
Definition IVertexBuffer.h:17
Main header file of the irrlicht, the only file needed to include.
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
Definition SMeshInstancingGroup.h:38