Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
light.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
#include "
node_3d.hpp
"
11
12
#include <
toast/export.hpp
>
13
14
namespace
toast {
15
17
enum class
LightType
: uint8_t {
18
none,
19
point,
20
directional,
21
spot,
22
ambient,
23
};
24
25
class
[[ToastNode, Hidden, Icon(
"PointLight"
)]] TOAST_API Light :
public
Node3D
{
26
public
:
27
Light() =
default
;
28
29
[[nodiscard]]
30
auto
lightType()
const
->
LightType
{
31
return
m_light_type;
32
}
33
34
[[nodiscard]]
35
auto
color()
const
->
const
glm::vec3& {
36
return
m_light_color;
37
}
38
39
[[nodiscard]]
40
auto
intensity()
const
->
float
{
41
return
m_intensity;
42
}
43
45
[[nodiscard]]
46
auto
castsShadows
() const ->
bool
{
47
return
m_cast_shadows;
48
}
49
51
[[nodiscard]]
52
auto
shadowResolutionScale
() const ->
float
{
53
return
m_shadow_resolution_scale;
54
}
55
57
[[nodiscard]]
58
auto
shadowDistance
() const ->
float
{
59
return
m_shadow_distance;
60
}
61
63
[[nodiscard]]
64
auto
cullDistance
() const ->
float
{
65
return
m_cull_distance;
66
}
67
68
protected
:
70
void
setLightType
(
LightType
type
) { m_light_type =
type
; }
71
72
private
:
73
void
init();
74
void
end();
75
void
destroy();
76
77
[[
Reflect
, Color]]
78
glm::vec3 m_light_color = glm::vec3(1.0f, 1.0f, 1.0f);
79
80
[[
Reflect
, Unit(
"lm"
)]]
81
float
m_intensity = 1.0f;
82
83
[[
Reflect
, Name(
"Cast Shadows"
), Group(
"Optimization"
)]]
84
bool
m_cast_shadows =
true
;
85
90
[[
Reflect
, Name(
"Shadow Resolution Scale"
), Range(0.1, 1.0), Group(
"Optimization"
)]]
91
float
m_shadow_resolution_scale = 1.0f;
92
96
[[
Reflect
, Name(
"Shadow Distance"
), Unit(
"m"
), Group(
"Optimization"
)]]
97
float
m_shadow_distance = 60.0f;
98
102
[[
Reflect
, Name(
"Cull Distance"
), Unit(
"m"
), Group(
"Optimization"
)]]
103
float
m_cull_distance = 0.0f;
104
105
// Deliberately not [[Reflect]] - applyFields() only ever touches reflected fields during prefab
106
// deserialization, so this constructor-set value can never be clobbered
107
LightType
m_light_type = LightType::none;
108
109
bool
m_registered_proxy =
false
;
110
};
111
}
toast::Light::shadowResolutionScale
auto shadowResolutionScale() const -> float
Multiplier on the shadow-map resolution this light is granted, see m_shadow_resolution_scale.
Definition
light.hpp:52
toast::Light::setLightType
void setLightType(LightType type)
Tags the concrete light kind; called once from each subclass's own constructor body.
Definition
light.hpp:70
toast::Light::castsShadows
auto castsShadows() const -> bool
Whether this light should be rendered into a shadow map.
Definition
light.hpp:46
toast::Light::shadowDistance
auto shadowDistance() const -> float
Camera distance past which this light stops casting shadows; 0 disables the limit.
Definition
light.hpp:58
toast::Light::cullDistance
auto cullDistance() const -> float
Camera distance past which this light stops being submitted at all; 0 disables the limit.
Definition
light.hpp:64
toast::Node3D
Definition
node_3d.hpp:25
toast::Node::type
auto type() const noexcept -> NodeType
Definition
node.hpp:192
toast::Reflect
Definition
reflect.hpp:244
export.hpp
toast::LightType
LightType
Concrete light kind, tagged once by each subclass's constructor - not RTTI, not reflected.
Definition
light.hpp:17
node_3d.hpp
Node with 3D spatial transforms.
engine
src
toast
world
light.hpp
Generated by
1.17.0