Skylicht Engine
Loading...
Searching...
No Matches
CDeferredRP.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 "CBaseRP.h"
28#include "CPostProcessorRP.h"
29
30namespace Skylicht
31{
91 class SKYLICHT_API CDeferredRP :
92 public CBaseRP,
93 public IEventReceiver
94 {
95 protected:
96 ITexture* m_target;
97
98 ITexture* m_albedo;
99 ITexture* m_position;
100 ITexture* m_normal;
101 ITexture* m_data;
102 ITexture* m_indirect;
103
104 ITexture* m_lightBuffer;
105
106 core::dimension2du m_size;
107
108 core::array<irr::video::IRenderTarget> m_multiRenderTarget;
109
110 core::matrix4 m_viewMatrix;
111 core::matrix4 m_projectionMatrix;
112
113 bool m_isIndirectPass;
114 int m_vertexColorShader;
115 int m_textureColorShader;
116 int m_textureLinearRGBShader;
117
118 int m_lightmapArrayShader;
119 int m_lightmapVertexShader;
120 int m_lightmapSHShader;
121 int m_lightmapSkinSHShader;
122 int m_lightmapColorShader;
123 int m_lightmapIndirectTestShader;
124
125 int m_colorInstancing;
126 int m_lmInstancingStandardSG;
127 int m_lmInstancingTangentSG;
128
129 int m_lightDirection;
130 int m_lightDirectionSSR;
131 int m_lightDirectionBake;
132
133 SMaterial m_lightPass;
134 SMaterial m_directionalLightPass;
135 SMaterial m_finalPass;
136
137 int m_pointLightShader;
138 int m_pointLightShadowShader;
139
140 int m_spotLightShader;
141 int m_spotLightShadowShader;
142
143 int m_areaLightShader;
144 int m_areaLightShadowShader;
145
146 float m_indirectMultipler;
147 float m_directMultipler;
148 float m_lightMultipler;
149
150 IPostProcessor* m_postProcessor;
151
152 protected:
153
154 void initDefferredMaterial();
155 void initLightMaterial();
156
157 public:
158 CDeferredRP();
159
160 virtual ~CDeferredRP();
161
162 virtual bool OnEvent(const SEvent& event);
163
164 virtual bool canRenderMaterial(CMaterial* material);
165
166 virtual bool canRenderShader(CShader* shader);
167
168 virtual void initRender(int w, int h);
169
170 virtual void resize(int w, int h);
171
172 virtual void render(ITexture* target, CCamera* camera, CEntityManager* entityManager, const core::recti& viewport, int cubeFaceId = -1, IRenderPipeline* lastRP = NULL);
173
174 virtual void drawMeshBuffer(CMesh* mesh, int bufferID, CEntityManager* entity, int entityID, bool skinnedMesh);
175
176 virtual void drawInstancingMeshBuffer(CMesh* mesh, int bufferID, CShader* instancingShader, CEntityManager* entityMgr, int entityID, bool skinnedMesh);
177
178 void getRenderLightRect(CCamera* camera, const core::aabbox3df& box, float& x, float& y, float& w, float& h, float maxW, float maxH);
179
180 inline void setPostProcessor(IPostProcessor* pp)
181 {
182 m_postProcessor = pp;
183 }
184
185 inline void setIndirectMultipler(float f)
186 {
187 m_indirectMultipler = f;
188 }
189
190 inline void setDirectMultipler(float f)
191 {
192 m_directMultipler = f;
193 }
194
195 inline void setLightMultipler(float f)
196 {
197 m_lightMultipler = f;
198 }
199
200 static void enableRenderIndirect(bool b);
201
202 static bool isEnableRenderIndirect();
203
204 static void enableTestIndirect(bool b);
205
206 static void enableTestBuffer(int bufferId);
207
208 protected:
209
210 void initRTT(int w, int h);
211
212 void releaseRTT();
213
214 };
215}
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
virtual bool OnEvent(const SEvent &event)
Called if an event happened.
This object class manages all entities within a scene.
Definition CEntityManager.h:89
The object class describes material information such as which shader it's associated with,...
Definition CMaterial.h:84
Definition CMesh.h:75
Represents a programmable shader, including uniforms, UI, resources, instancing and platform-specific...
Definition CShader.h:198
Definition IPostProcessor.h:32
Definition IRenderPipeline.h:37
Interface of an object which can receive events.
Definition IEventReceiver.h:474
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
Interface of a Video Driver dependent Texture.
Definition ITexture.h:119
Struct for holding parameters for a material renderer.
Definition SMaterial.h:255
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
rect< s32 > recti
Rectangle with int values.
Definition rect.h:273
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
dimension2d< u32 > dimension2du
Typedef for an unsigned integer dimension.
Definition dimension2d.h:212
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Definition IEventReceiver.h:273