Skylicht Engine
Loading...
Searching...
No Matches
CShadowMapRP.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 "Shadow/CCascadedShadowMaps.h"
29#include "Shadow/CShadowMaps.h"
30#include "Shadow/CBoundShadowMaps.h"
31#include "EventManager/CEventManager.h"
32
33namespace Skylicht
34{
56 class SKYLICHT_API CShadowMapRP :
57 public CBaseRP,
58 public IEventProcessor
59 {
60 public:
61 enum EShadowMapType
62 {
63 CascadedShadow = 0,
64 ShadowMapping
65 };
66
67 enum ERenderShadowState
68 {
69 DirectionLight = 0,
70 PointLight,
71 AreaLight,
72 };
73
74 protected:
75 EShadowMapType m_shadowMapType;
76 ERenderShadowState m_renderShadowState;
77
78 ITexture* m_depthTexture;
79
80 float m_shadowFar;
81 int m_shadowMapSize;
82
83 int m_numCascade;
84
85 int m_screenWidth;
86 int m_screenHeight;
87
88 SMaterial m_writeDepthMaterial;
89 core::vector3df m_lightDirection;
90
91 CBoundShadowMaps* m_lsm;
92 CShadowMaps* m_sm;
94 int m_currentCSM;
95
96 int m_texColorShader;
97 int m_skinShader;
98
99 int m_depthWriteShader;
100 int m_depthWriteSkinMeshShader;
101 int m_distanceWriteShader;
102 int m_distanceWriteSkinMeshShader;
103
104 int m_depthWriteSkinnedInstancing;
105
106 bool m_saveDebug;
107 bool m_saveDebugPL;
108 public:
109 CShadowMapRP();
110
111 virtual ~CShadowMapRP();
112
113 void release();
114
115 void setShadowCascade(int numCascade, int shadowMapSize = 2048, float farValue = 300.0f);
116
117 void setNoShadowCascade(int shadowMapSize = 2048, float farValue = 50.0f);
118
119 void setShadowMapping(EShadowMapType type);
120
121 virtual void initRender(int w, int h);
122
123 virtual void resize(int w, int h);
124
125 virtual void render(ITexture* target, CCamera* camera, CEntityManager* entityManager, const core::recti& viewport, int cubeFaceId = -1, IRenderPipeline* lastRP = NULL);
126
127 virtual bool canRenderMaterial(CMaterial* m);
128
129 virtual bool canRenderShader(CShader* s);
130
131 virtual void drawMeshBuffer(CMesh* mesh, int bufferID, CEntityManager* entity, int entityID, bool skinnedMesh);
132
133 virtual void drawInstancingMeshBuffer(CMesh* mesh, int bufferID, CShader* instancingShader, CEntityManager* entityMgr, int entityID, bool skinnedMesh);
134
135 virtual bool OnProcessEvent(const SEvent& event);
136
137 public:
138
139 virtual void updateShaderResource(CShader* shader, CEntityManager* entity, int entityID, video::SMaterial& irrMaterial);
140
141 virtual const core::aabbox3df& getFrustumBox();
142
143 inline ITexture* getDepthTexture()
144 {
145 return m_depthTexture;
146 }
147
148 virtual float* getShadowDistance();
149
150 virtual float* getShadowMatrices();
151
152 inline ERenderShadowState getRenderShadowState()
153 {
154 return m_renderShadowState;
155 }
156
157 protected:
158 CCascadedShadowMaps* getCSM()
159 {
160 return m_csm;
161 }
162 };
163}
Definition CBoundShadowMaps.h:32
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
Definition CCascadedShadowMaps.h:35
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 CShadowMaps.h:33
Definition CEventManager.h:32
Definition IRenderPipeline.h:37
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
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
rect< s32 > recti
Rectangle with int values.
Definition rect.h:273
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