vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
light_data.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <glm/glm.hpp>
7
8#include "ecs/component/render/light.h"
9
10namespace Vkm::Engine {
11
18struct LightData {
19 LightType type;
20
28 uint32_t entitySlot = 0;
29 glm::vec3 color;
30 float intensity;
31 float wave = 1.0f;
32 glm::vec3 position;
33
34 glm::vec3 direction;
35
36 float radius;
37
40
41 // Area-light fields, zero for punctual lights.
42 glm::vec3 axisU{0.0f};
43 glm::vec3 axisV{0.0f};
44 bool twoSided;
45
46 bool castShadows;
47 float shadowBias;
51
58 float sourceRadius = 0.0f;
59
62 bool transient = false;
63};
64
74inline const LightData* lowestSlotDirectional(const std::vector<LightData>& lights) {
75 const LightData* key = nullptr;
76 for (const LightData& light : lights) {
77 if (light.type != LightType::Directional) continue;
78 if (!key || light.entitySlot < key->entitySlot) key = &light;
79 }
80 return key;
81}
82
91inline const LightData* lowestSlotDirectionalCaster(const std::vector<LightData>& lights) {
92 const LightData* sun = nullptr;
93 for (const LightData& light : lights) {
94 if (light.type != LightType::Directional || !light.castShadows) continue;
95 if (!sun || light.entitySlot < sun->entitySlot) sun = &light;
96 }
97 return sun;
98}
99
100} // namespace Vkm::Engine
One light affecting the frame, resolved to world space.
Definition light_data.h:18
bool transient
Definition light_data.h:62
float shadowNormalBias
See Light::shadowNormalBias.
Definition light_data.h:48
glm::vec3 axisU
Rect/Disk: half-right world axis.
Definition light_data.h:42
int shadowPriority
See Light::shadowPriority.
Definition light_data.h:50
float radius
Attenuation radius (point/spot/area)
Definition light_data.h:36
float shadowBias
See Light::shadowBias.
Definition light_data.h:47
float innerConeAngle
Spot: full-brightness cone (radians)
Definition light_data.h:38
float shadowDistance
Directional only: world distance the cascades cover.
Definition light_data.h:49
bool twoSided
Rect/Disk: emit from both faces.
Definition light_data.h:44
uint32_t entitySlot
The entity slot this light was gathered from.
Definition light_data.h:28
glm::vec3 axisV
Rect/Disk: half-up world axis.
Definition light_data.h:43
float outerConeAngle
Spot: falloff edge (radians)
Definition light_data.h:39
float sourceRadius
Light::sourceRadius: radians for a directional light, metres otherwise.
Definition light_data.h:58
glm::vec3 direction
Travel direction; used by directional/spot.
Definition light_data.h:34
float wave
The share of intensity it shines with this frame (flickerWave)
Definition light_data.h:31