vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
light.h
1#pragma once
2
3#include <glm/glm.hpp>
4
5#include "core/reflect.h"
6#include "ecs/entity.h"
7
8namespace Vkm::Engine {
9
10class Scene;
11
18enum class LightType {
19 Directional = 0,
20 Point = 1,
21 Spot = 2,
22 Rect = 3,
23 Disk = 4,
24 Count
25};
26
34struct Light {
35 LightType type = LightType::Directional;
36 glm::vec3 color = {1.0f, 1.0f, 1.0f};
37 float intensity = 1.0f;
38
39 float radius = 10.0f;
40
41 float innerConeAngle = 0.5f;
42 float outerConeAngle = 0.785f;
43
44 float areaWidth = 1.0f;
45 float areaHeight = 1.0f;
46 float areaRadius = 0.5f;
47 bool twoSided = false;
48
49 bool castShadows = true;
50
57 float shadowBias = 0.005f;
58
64 float shadowNormalBias = 1.5f;
65 float shadowDistance = 100.0f;
66
74 float sourceRadius = glm::radians(0.5f);
75
76 bool enabled = true;
77};
78
88EntityId findKeyLight(const Scene& scene);
89
90} // namespace Vkm::Engine
91
92VKM_ENUM_NAMES(::Vkm::Engine::LightType, "Directional", "Point", "Spot", "Rect", "Disk")
93
94VKM_REFLECT_BEGIN(::Vkm::Engine::Light)
95 VKM_F(type)
96 VKM_F(color)
97 VKM_F(intensity)
98 VKM_F(radius)
99 VKM_F(innerConeAngle)
100 VKM_F(outerConeAngle)
101 VKM_F(areaWidth)
102 VKM_F(areaHeight)
103 VKM_F(areaRadius)
104 VKM_F(twoSided)
105 VKM_F(castShadows)
106 VKM_F(shadowBias)
107 VKM_F(shadowNormalBias)
108 VKM_F(shadowDistance)
109 VKM_F(sourceRadius)
110 VKM_F(enabled)
111VKM_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:34
float areaWidth
Rect width along the local X axis.
Definition light.h:44
float radius
Attenuation cutoff (point/spot/area)
Definition light.h:39
float shadowDistance
Directional only: world distance the cascades cover.
Definition light.h:65
float areaHeight
Rect height along the local Y axis.
Definition light.h:45
float areaRadius
Disk radius.
Definition light.h:46
float sourceRadius
How large the light's source is, which is how soft its shadows are.
Definition light.h:74
float shadowNormalBias
Directional and spot: normal offset before the depth compare, in shadow texels (0....
Definition light.h:64
float outerConeAngle
Spot: falloff edge, radians.
Definition light.h:42
bool twoSided
Area lights: emit from both faces.
Definition light.h:47
float innerConeAngle
Spot: full-brightness cone, radians.
Definition light.h:41
float shadowBias
Depth comparison bias, grown at grazing light.
Definition light.h:57