vkmEngine 1.0.0
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 glm::vec3 position;
32
33 glm::vec3 direction;
34
35 float radius;
36
39
40 // Area-light fields, zero for punctual lights.
41 glm::vec3 axisU{0.0f};
42 glm::vec3 axisV{0.0f};
43 bool twoSided;
44
45 bool castShadows;
46 float shadowBias;
49
56 float sourceRadius = 0.0f;
57};
58
68inline const LightData* lowestSlotDirectional(const std::vector<LightData>& lights) {
69 const LightData* key = nullptr;
70 for (const LightData& light : lights) {
71 if (light.type != LightType::Directional) continue;
72 if (!key || light.entitySlot < key->entitySlot) key = &light;
73 }
74 return key;
75}
76
77} // namespace Vkm::Engine
One light affecting the frame, resolved to world space.
Definition light_data.h:18
float shadowNormalBias
2D only: normal offset before the compare, in shadow texels
Definition light_data.h:47
glm::vec3 axisU
Rect/Disk: half-right world axis.
Definition light_data.h:41
float radius
Attenuation radius (point/spot/area)
Definition light_data.h:35
float shadowBias
See Light::shadowBias.
Definition light_data.h:46
float innerConeAngle
Spot: full-brightness cone (radians)
Definition light_data.h:37
float shadowDistance
Directional only: world distance the cascades cover.
Definition light_data.h:48
bool twoSided
Rect/Disk: emit from both faces.
Definition light_data.h:43
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:42
float outerConeAngle
Spot: falloff edge (radians)
Definition light_data.h:38
float sourceRadius
Light::sourceRadius: radians for a directional light, metres otherwise.
Definition light_data.h:56
glm::vec3 direction
Travel direction; used by directional/spot.
Definition light_data.h:33