SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Light.hpp
Go to the documentation of this file.
1#ifndef _LIGHT_HPP_
2#define _LIGHT_HPP_
3
4#include <Core/GameObject.hpp>
5#include <Math/Vector.hpp>
6#include <Math/Color.hpp>
7#include <cmath>
8
9namespace Sleak {
10
11 namespace RenderEngine {
12 struct LightGPUEntry;
13 }
14
15 /// Base class for every light type; owns the color/intensity/shadow parameters LightManager uploads to the GPU.
16 /// @ingroup lighting
17 class ENGINE_API Light : public GameObject {
18 public:
19 explicit Light(const std::string& name = "Light");
20 ~Light() override = default;
21
22 bool IsLight() const override { return true; }
23
24 /// Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
26
27 void SetColor(float r, float g, float b);
28 void SetColor(const Math::Color& color);
29 Math::Vector3D GetColor() const { return m_color; }
30
31 void SetIntensity(float intensity) {
32 m_intensity = intensity;
33 }
34 float GetIntensity() const { return m_intensity; }
35
36 void SetEnabled(bool enabled) { m_lightEnabled = enabled; }
37 bool IsEnabled() const { return m_lightEnabled; }
38
39 void SetCastShadows(bool cast) { m_castShadows = cast; }
40 bool GetCastShadows() const { return m_castShadows; }
41
42 void SetShadowBias(float bias) { m_shadowBias = bias; }
43 float GetShadowBias() const { return m_shadowBias; }
44
45 void SetShadowStrength(float strength) {
46 m_shadowStrength = strength;
47 }
48 float GetShadowStrength() const { return m_shadowStrength; }
49
50 void SetShadowNormalBias(float bias) { m_shadowNormalBias = bias; }
51 float GetShadowNormalBias() const { return m_shadowNormalBias; }
52
53 void SetLightSize(float size) { m_lightSize = size; }
54 float GetLightSize() const { return m_lightSize; }
55
56 protected:
57 Math::Vector3D m_color{1.0f, 1.0f, 1.0f};
58 float m_intensity = 1.0f;
59 bool m_lightEnabled = true;
60 bool m_castShadows = false;
61 float m_shadowBias = 0.005f;
62 float m_shadowStrength = 1.0f;
63 float m_shadowNormalBias = 0.02f;
64 float m_lightSize = 1.0f;
65 };
66
67} // namespace Sleak
68
69#endif // _LIGHT_HPP_
GameObject(const std::string &name="GameObject")
Math::Vector3D m_color
Definition Light.hpp:57
virtual RenderEngine::LightGPUEntry BuildGPUData() const =0
Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
bool GetCastShadows() const
Definition Light.hpp:40
Light(const std::string &name="Light")
Definition Light.cpp:5
void SetColor(float r, float g, float b)
Definition Light.cpp:7
bool IsEnabled() const
Definition Light.hpp:37
void SetShadowBias(float bias)
Definition Light.hpp:42
float GetIntensity() const
Definition Light.hpp:34
float m_lightSize
Definition Light.hpp:64
float m_shadowBias
Definition Light.hpp:61
float GetShadowStrength() const
Definition Light.hpp:48
Math::Vector3D GetColor() const
Definition Light.hpp:29
float m_shadowNormalBias
Definition Light.hpp:63
void SetShadowNormalBias(float bias)
Definition Light.hpp:50
void SetCastShadows(bool cast)
Definition Light.hpp:39
bool m_castShadows
Definition Light.hpp:60
void SetLightSize(float size)
Definition Light.hpp:53
float m_shadowStrength
Definition Light.hpp:62
float GetShadowBias() const
Definition Light.hpp:43
bool m_lightEnabled
Definition Light.hpp:59
void SetEnabled(bool enabled)
Definition Light.hpp:36
void SetShadowStrength(float strength)
Definition Light.hpp:45
float GetShadowNormalBias() const
Definition Light.hpp:51
float GetLightSize() const
Definition Light.hpp:54
void SetIntensity(float intensity)
Definition Light.hpp:31
~Light() override=default
float m_intensity
Definition Light.hpp:58
bool IsLight() const override
Definition Light.hpp:22
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10
One light's packed GPU representation, laid out for std140/cbuffer alignment.