Nameless Engine
Loading...
Searching...
No Matches
DirectionalLightNode.h
1#pragma once
2
3// Custom.
4#include "game/nodes/SpatialNode.h"
5#include "math/GLMath.hpp"
6#include "shader/VulkanAlignmentConstants.hpp"
7#include "shader/general/resource/LightingShaderResourceManager.h"
8#include "render/general/resource/shadow/ShadowMapHandle.h"
9
10#include "DirectionalLightNode.generated.h"
11
12namespace ne RNAMESPACE() {
14 class RCLASS(Guid("7c95023e-c185-46af-8745-79fc0b59bbb3")) DirectionalLightNode : public SpatialNode {
15 // Renderer reads shadow map handle and index into viewProjection matrix array.
16 friend class Renderer;
17
18 public:
20
26 DirectionalLightNode(const std::string& sNodeName);
27
28 virtual ~DirectionalLightNode() override = default;
29
35 void setLightColor(const glm::vec3& color);
36
42 void setLightIntensity(float intensity);
43
49 glm::vec3 getLightColor() const;
50
56 float getLightIntensity() const;
57
58 protected:
66 virtual void onAfterDeserialized() override;
67
80 virtual void onSpawning() override;
81
91 virtual void onDespawning() override;
92
102 virtual void onWorldLocationRotationScaleChanged() override;
103
104 private:
107 DirecionalLightShaderData() = default;
108
113 alignas(iVkMat4Alignment) glm::mat4 viewProjectionMatrix = glm::identity<glm::mat4>();
114
116 alignas(iVkVec4Alignment) glm::vec4 direction = glm::vec4(0.0F, 0.0F, 0.0F, 0.0F);
117
119 alignas(iVkVec4Alignment) glm::vec4 color = glm::vec4(1.0F, 1.0F, 1.0F, 1.0F);
120
122 alignas(iVkScalarAlignment) float intensity = 1.0F;
123
125 alignas(iVkScalarAlignment) unsigned int iShadowMapIndex = 0;
126 };
127
129 struct ShaderData {
130 ShaderData() = default;
131
134 ShadowPassDataGroup() = default;
135
137 std::unique_ptr<ShaderLightArraySlot> pSlot;
138
141 };
142
144 std::unique_ptr<ShaderLightArraySlot> pDirectionalLightArraySlot;
145
148
151 };
152
160 ShadowMapHandle* getShadowMapHandle() const;
161
168 unsigned int getIndexIntoShadowPassInfoShaderArray();
169
176 void* onStartedUpdatingShaderData();
177
182 void onFinishedUpdatingShaderData();
183
190 void* onStartedUpdatingShadowPassData();
191
196 void onFinishedUpdatingShadowPassData();
197
204 void markShadowPassDataToBeCopiedToGpu();
205
212 void markShaderDataToBeCopiedToGpu();
213
219 void onShadowMapArrayIndexChanged(unsigned int iNewIndexIntoArray);
220
226 void recalculateShadowMappingShaderData();
227
229 std::pair<std::recursive_mutex, ShaderData> mtxShaderData;
230
236 std::unique_ptr<ShadowMapHandle> pShadowMapHandle;
237
239 RPROPERTY(Serialize)
240 glm::vec3 color = glm::vec3(1.0F, 1.0F, 1.0F);
241
243 RPROPERTY(Serialize)
244 float intensity = 1.0F;
245
246 ne_DirectionalLightNode_GENERATED
247 };
248}
249
250File_DirectionalLightNode_GENERATED
Definition: DirectionalLightNode.h:14
std::pair< std::recursive_mutex, ShaderData > mtxShaderData
Definition: DirectionalLightNode.h:229
std::unique_ptr< ShadowMapHandle > pShadowMapHandle
Definition: DirectionalLightNode.h:236
Definition: GuidProperty.h:30
Definition: Renderer.h:43
Definition: SerializeProperty.h:42
Definition: ShadowMapHandle.h:23
Definition: SpatialNode.h:12
Definition: DirectionalLightNode.h:106
Definition: DirectionalLightNode.h:133
std::unique_ptr< ShaderLightArraySlot > pSlot
Definition: DirectionalLightNode.h:137
ShadowPassLightShaderInfo shaderData
Definition: DirectionalLightNode.h:140
Definition: DirectionalLightNode.h:129
std::unique_ptr< ShaderLightArraySlot > pDirectionalLightArraySlot
Definition: DirectionalLightNode.h:144
ShadowPassDataGroup shadowPassData
Definition: DirectionalLightNode.h:147
DirecionalLightShaderData shaderData
Definition: DirectionalLightNode.h:150
Definition: LightingShaderResourceManager.h:38