Nameless Engine
Loading...
Searching...
No Matches
PointLightNode.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 "misc/shapes/Sphere.h"
9#include "render/general/resource/shadow/ShadowMapHandle.h"
10
11#include "PointLightNode.generated.h"
12
13namespace ne RNAMESPACE() {
15 class RCLASS(Guid("7890ed17-6efb-43d1-a7ef-aa5a0589921a")) PointLightNode : public SpatialNode {
16 // Renderer reads shadow map handle and index into viewProjection matrix array.
17 friend class Renderer;
18
19 public:
21
27 PointLightNode(const std::string& sNodeName);
28
29 virtual ~PointLightNode() override = default;
30
36 void setLightColor(const glm::vec3& color);
37
43 void setLightIntensity(float intensity);
44
50 void setLightDistance(float distance);
51
57 glm::vec3 getLightColor() const;
58
64 float getLightIntensity() const;
65
71 float getLightDistance() const;
72
84 std::pair<std::mutex, Sphere>* getShape();
85
86 protected:
94 virtual void onAfterDeserialized() override;
95
108 virtual void onSpawning() override;
109
119 virtual void onDespawning() override;
120
130 virtual void onWorldLocationRotationScaleChanged() override;
131
132 private:
135 PointLightShaderData() = default;
136
138 alignas(iVkVec4Alignment) glm::vec4 position = glm::vec4(0.0F, 0.0F, 0.0F, 1.0F);
139
141 alignas(iVkVec4Alignment) glm::vec4 color = glm::vec4(1.0F, 1.0F, 1.0F, 1.0F);
142
144 alignas(iVkScalarAlignment) float intensity = 1.0F;
145
147 alignas(iVkScalarAlignment) float distance = 1.0F;
148
150 alignas(iVkScalarAlignment) unsigned int iShadowMapIndex = 0;
151 };
152
154 struct ShaderData {
155 ShaderData() = default;
156
159 ShadowPassDataGroup() = default;
160
162 std::unique_ptr<ShaderLightArraySlot> pSlot;
163
166 };
167
169 std::unique_ptr<ShaderLightArraySlot> pPointLightArraySlot;
170
172 std::array<ShadowPassDataGroup, 6> vShadowPassDataGroup;
173
176 };
177
185 ShadowMapHandle* getShadowMapHandle() const;
186
195 unsigned int getIndexIntoShadowPassInfoShaderArray(size_t iCubemapFaceIndex = 0);
196
203 void* onStartedUpdatingShaderData();
204
209 void onFinishedUpdatingShaderData();
210
219 void* onStartedUpdatingShadowPassData(size_t iCubemapFaceIndex);
220
225 void onFinishedUpdatingShadowPassData();
226
233 void markShaderDataToBeCopiedToGpu();
234
241 void markShadowPassDataToBeCopiedToGpu();
242
248 void onShadowMapArrayIndexChanged(unsigned int iNewIndexIntoArray);
249
255 void recalculateShadowPassShaderData();
256
262 void recalculateShape();
263
265 std::pair<std::recursive_mutex, ShaderData> mtxShaderData;
266
272 std::pair<std::mutex, Sphere> mtxShape;
273
279 std::unique_ptr<ShadowMapHandle> pShadowMapHandle;
280
282 RPROPERTY(Serialize)
283 glm::vec3 color = glm::vec3(1.0F, 1.0F, 1.0F);
284
286 RPROPERTY(Serialize)
287 float intensity = 1.0F;
288
290 RPROPERTY(Serialize)
291 float distance = 10.0F; // NOLINT: seems like a pretty good default value
292
293 ne_PointLightNode_GENERATED
294 };
295}
296
297File_PointLightNode_GENERATED
Definition: GuidProperty.h:30
Definition: PointLightNode.h:15
std::pair< std::recursive_mutex, ShaderData > mtxShaderData
Definition: PointLightNode.h:265
std::pair< std::mutex, Sphere > mtxShape
Definition: PointLightNode.h:272
std::unique_ptr< ShadowMapHandle > pShadowMapHandle
Definition: PointLightNode.h:279
Definition: Renderer.h:43
Definition: SerializeProperty.h:42
Definition: ShadowMapHandle.h:23
Definition: SpatialNode.h:12
Definition: PointLightNode.h:134
ShadowPassLightShaderInfo shaderData
Definition: PointLightNode.h:165
std::unique_ptr< ShaderLightArraySlot > pSlot
Definition: PointLightNode.h:162
Definition: PointLightNode.h:154
std::unique_ptr< ShaderLightArraySlot > pPointLightArraySlot
Definition: PointLightNode.h:169
PointLightShaderData shaderData
Definition: PointLightNode.h:175
std::array< ShadowPassDataGroup, 6 > vShadowPassDataGroup
Definition: PointLightNode.h:172
Definition: LightingShaderResourceManager.h:38