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
9
namespace
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.
25
virtual
RenderEngine::LightGPUEntry
BuildGPUData
()
const
= 0;
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_
Color.hpp
GameObject.hpp
Vector.hpp
Sleak::GameObject::GameObject
GameObject(const std::string &name="GameObject")
Definition
GameObject.hpp:59
Sleak::Light::m_color
Math::Vector3D m_color
Definition
Light.hpp:57
Sleak::Light::BuildGPUData
virtual RenderEngine::LightGPUEntry BuildGPUData() const =0
Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
Sleak::Light::GetCastShadows
bool GetCastShadows() const
Definition
Light.hpp:40
Sleak::Light::Light
Light(const std::string &name="Light")
Definition
Light.cpp:5
Sleak::Light::SetColor
void SetColor(float r, float g, float b)
Definition
Light.cpp:7
Sleak::Light::IsEnabled
bool IsEnabled() const
Definition
Light.hpp:37
Sleak::Light::SetShadowBias
void SetShadowBias(float bias)
Definition
Light.hpp:42
Sleak::Light::GetIntensity
float GetIntensity() const
Definition
Light.hpp:34
Sleak::Light::m_lightSize
float m_lightSize
Definition
Light.hpp:64
Sleak::Light::m_shadowBias
float m_shadowBias
Definition
Light.hpp:61
Sleak::Light::GetShadowStrength
float GetShadowStrength() const
Definition
Light.hpp:48
Sleak::Light::GetColor
Math::Vector3D GetColor() const
Definition
Light.hpp:29
Sleak::Light::m_shadowNormalBias
float m_shadowNormalBias
Definition
Light.hpp:63
Sleak::Light::SetShadowNormalBias
void SetShadowNormalBias(float bias)
Definition
Light.hpp:50
Sleak::Light::SetCastShadows
void SetCastShadows(bool cast)
Definition
Light.hpp:39
Sleak::Light::m_castShadows
bool m_castShadows
Definition
Light.hpp:60
Sleak::Light::SetLightSize
void SetLightSize(float size)
Definition
Light.hpp:53
Sleak::Light::m_shadowStrength
float m_shadowStrength
Definition
Light.hpp:62
Sleak::Light::GetShadowBias
float GetShadowBias() const
Definition
Light.hpp:43
Sleak::Light::m_lightEnabled
bool m_lightEnabled
Definition
Light.hpp:59
Sleak::Light::SetEnabled
void SetEnabled(bool enabled)
Definition
Light.hpp:36
Sleak::Light::SetShadowStrength
void SetShadowStrength(float strength)
Definition
Light.hpp:45
Sleak::Light::GetShadowNormalBias
float GetShadowNormalBias() const
Definition
Light.hpp:51
Sleak::Light::GetLightSize
float GetLightSize() const
Definition
Light.hpp:54
Sleak::Light::SetIntensity
void SetIntensity(float intensity)
Definition
Light.hpp:31
Sleak::Light::~Light
~Light() override=default
Sleak::Light::m_intensity
float m_intensity
Definition
Light.hpp:58
Sleak::Light::IsLight
bool IsLight() const override
Definition
Light.hpp:22
Sleak::Math::Color
Definition
Color.hpp:16
Sleak::Math::Vector3D
Definition
Vector.hpp:353
Sleak::RenderEngine
Backend-facing rendering layer shared by the four graphics backends.
Definition
Application.hpp:60
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
Sleak::RenderEngine::LightGPUEntry
One light's packed GPU representation, laid out for std140/cbuffer alignment.
Definition
ConstantBuffer.hpp:20
include
public
Lighting
Light.hpp
Generated on
for SleakEngine by
1.16.1