vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
light.h
1#pragma once
2
3#include <cstdint>
4
5#include <glm/glm.hpp>
6
7#include "core/reflect.h"
8#include "ecs/entity.h"
9
10namespace Vkm::Engine {
11
12class Scene;
13
20enum class LightType {
21 Directional = 0,
22 Point = 1,
23 Spot = 2,
24 Rect = 3,
25 Disk = 4,
26 Count
27};
28
36struct Light {
37 LightType type = LightType::Directional;
38 glm::vec3 color = {1.0f, 1.0f, 1.0f};
39 float intensity = 1.0f;
40
41 float radius = 10.0f;
42
43 float innerConeAngle = 0.5f;
44 float outerConeAngle = 0.785f;
45
46 float areaWidth = 1.0f;
47 float areaHeight = 1.0f;
48 float areaRadius = 0.5f;
49 bool twoSided = false;
50
51 bool castShadows = true;
52
60 float shadowBias = 0.5f;
61
68 float shadowNormalBias = 1.0f;
69 float shadowDistance = 100.0f;
70
78
87 float sourceRadius = glm::radians(0.5f);
88
96 float flicker = 0.0f;
97
98 bool enabled = true;
99};
100
114float flickerWave(const Light& light, double seconds, uint32_t slot);
115
125EntityId findKeyLight(const Scene& scene);
126
127} // namespace Vkm::Engine
128
129VKM_ENUM_NAMES(::Vkm::Engine::LightType, "Directional", "Point", "Spot", "Rect", "Disk")
130
131VKM_REFLECT_BEGIN(::Vkm::Engine::Light)
132 VKM_F(type)
133 VKM_F(color)
134 VKM_F(intensity)
135 VKM_F(radius)
136 VKM_F(innerConeAngle)
137 VKM_F(outerConeAngle)
138 VKM_F(areaWidth)
139 VKM_F(areaHeight)
140 VKM_F(areaRadius)
141 VKM_F(twoSided)
142 VKM_F(castShadows)
143 VKM_F(shadowBias)
144 VKM_F(shadowNormalBias)
145 VKM_F(shadowDistance)
146 VKM_F(shadowPriority)
147 VKM_F(sourceRadius)
148 VKM_F(flicker)
149 VKM_F(enabled)
150VKM_REFLECT_END()
Central registry managing entities and an open set of component types.
Definition scene.h:29
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
Component representing a light source in the scene.
Definition light.h:36
float areaWidth
Rect width along the local X axis.
Definition light.h:46
float radius
Attenuation cutoff (point/spot/area)
Definition light.h:41
float shadowDistance
Directional only: world distance the cascades cover.
Definition light.h:69
float areaHeight
Rect height along the local Y axis.
Definition light.h:47
float areaRadius
Disk radius.
Definition light.h:48
float flicker
How deep the light wavers, as a fire's does: 0 holds it steady, 1 dips it to dark.
Definition light.h:96
float sourceRadius
How large the light's source is, which is how soft its shadows are.
Definition light.h:87
float shadowNormalBias
How far the point moves off the surface before the compare, in shadow texels (0..4).
Definition light.h:68
float outerConeAngle
Spot: falloff edge, radians.
Definition light.h:44
bool twoSided
Area lights: emit from both faces.
Definition light.h:49
float innerConeAngle
Spot: full-brightness cone, radians.
Definition light.h:43
float shadowBias
How far the depth compare slides toward the light, in shadow texels (0..4).
Definition light.h:60
int shadowPriority
Which lights keep a shadow when more cast than the atlas holds; higher first.
Definition light.h:77