Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Shadow
CCascadedShadowMaps.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2019 Skylicht Technology CO., LTD
6
7
Permission 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,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "SFrustumSplit.h"
28
#include "Camera/CCamera.h"
29
30
#define MAX_FRUSTUM_SPLITS 8
31
32
namespace
Skylicht
33
{
34
class
SKYLICHT_API CCascadedShadowMaps
35
{
36
protected
:
37
float
m_lambda;
38
float
m_nearOffset;
39
int
m_splitCount;
40
int
m_shadowMapSize;
41
42
SFrustumSplit
m_splits[MAX_FRUSTUM_SPLITS];
43
float
m_farBounds[MAX_FRUSTUM_SPLITS];
44
45
core::vector3df
m_lightDirection;
46
47
core::matrix4
m_bias;
48
core::matrix4
m_viewMatrices[MAX_FRUSTUM_SPLITS];
49
core::matrix4
m_projMatrices[MAX_FRUSTUM_SPLITS];
50
core::matrix4
m_textureMatrices[MAX_FRUSTUM_SPLITS];
51
52
core::aabbox3df
m_frustumBox[MAX_FRUSTUM_SPLITS];
53
54
float
m_shadowMatrices[16 * MAX_FRUSTUM_SPLITS];
55
56
float
m_farValue;
57
58
public
:
59
CCascadedShadowMaps();
60
61
virtual
~CCascadedShadowMaps();
62
63
void
init(
int
splitCount,
int
shadowMapSize,
float
farValue,
int
screenWidth,
int
screenHeight);
64
65
void
update(
CCamera
*camera,
const
core::vector3df
& lightDir);
66
67
inline
const
core::aabbox3df
& getFrustumBox(
int
cascaded)
68
{
69
return
m_frustumBox[cascaded];
70
}
71
72
inline
int
getSplitCount()
73
{
74
return
m_splitCount;
75
}
76
77
inline
const
core::matrix4
& getViewMatrices(
int
i)
78
{
79
return
m_viewMatrices[i];
80
}
81
82
inline
const
core::matrix4
& getProjectionMatrices(
int
i)
83
{
84
return
m_projMatrices[i];
85
}
86
87
inline
float
* getShadowDistance()
88
{
89
return
m_farBounds;
90
}
91
92
inline
float
* getShadowMatrices()
93
{
94
return
m_shadowMatrices;
95
}
96
97
protected
:
98
99
void
updateSplits(
CCamera
*camera);
100
101
void
updateFrustumCorners(
const
core::vector3df
& camPos,
const
core::vector3df
& camForward);
102
103
void
updateMatrix(
core::vector3df
& camPos);
104
};
105
}
Skylicht::CCamera
This is an object class used to set up the camera, including its position, viewing angle,...
Definition
CCamera.h:70
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition
vector3d.h:445
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition
matrix4.h:2241
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition
aabbox3d.h:351
Skylicht::SFrustumSplit
Definition
SFrustumSplit.h:32
Generated by
1.17.0