35 {
return {1, 4.5f /
r, 75.0f / (
r *
r)}; }
44 float range()
const {
return 4.5f / this->att[1]; }
77 std::array<mat4, 7 * MAX_LIGHTS>
views = {};
86 {
return this->flags.
is_set(Flag::SHADOWS_ENABLED); }
Definition animation.h:71
float m_shadow_map_far
Definition light.h:75
void set_update_sun(bool b)
Definition light.cpp:85
size_t n_point
Definition light.h:71
bool update_sun(void) const
Definition light.h:84
void remove_light(Light *l)
Definition light.cpp:139
size_t n_dir
Definition light.h:71
std::array< mat4, 7 *MAX_LIGHTS > views
Definition light.h:77
Light * sun_light()
Definition light.h:92
std::span< const Light > point_lights() const
Definition light.h:123
mat4 m_point_proj
Definition light.h:76
float shadow_map_near() const
Definition light.h:94
void set_shadow_map_far(float f)
Definition light.cpp:114
const LightsUBO & ubo() const
Definition light.h:101
Light * add_light(Light::Type t)
Definition light.cpp:119
void update_view(const vec3 &eye)
Definition light.cpp:247
vec4 m_ambient_light
Definition light.h:69
void set_enabled(bool b)
Definition light.cpp:75
void set_zsprites(bool b)
Definition light.cpp:80
static constexpr size_t MAX_LIGHTS
Definition light.h:55
float shadow_map_far() const
Definition light.h:95
void init(Math *m)
Definition light.h:81
Math * math
Definition light.h:66
Sun * sun()
Definition light.h:102
Light * m_sun_light
Definition light.h:73
void set_ambient_anim(LightAnimation a)
Definition light.cpp:100
vec3 view_pos
Definition light.h:68
Sun m_sun
Definition light.h:79
float m_shadow_map_near
Definition light.h:75
std::array< Light, MAX_LIGHTS > m_point_lights
Definition light.h:72
bool enabled() const
Definition light.h:82
const mat4 & point_view(size_t i, size_t f) const
Definition light.h:99
void set_shadow_map_near(float f)
Definition light.cpp:109
void set_shadow_map_proj_size(float s)
Definition light.cpp:104
const mat4 & dir_proj() const
Definition light.h:96
const mat4 & dir_view(size_t i) const
Definition light.h:98
std::span< const Light > dir_lights() const
Definition light.h:119
std::array< Light, MAX_LIGHTS > m_dir_lights
Definition light.h:72
Flag
Definition light.h:57
@ ZSPRITES
Definition light.h:60
@ ENABLED
Definition light.h:58
@ SHADOWS_ENABLED
Definition light.h:59
@ UPDATE_SUN
Definition light.h:61
@ UPDATED
Definition light.h:62
@ VIEW_UPDATED
Definition light.h:63
@ SHADOW_MAPS_UPDATED
Definition light.h:64
const vec4 & ambient_light() const
Definition light.h:87
Flags< Flag > flags
Definition light.h:67
bool shadows_enabled(void) const
Definition light.h:85
void set_shadows_enabled(bool b)
Definition light.cpp:90
const Light * sun_light() const
Definition light.h:93
void set_sun_light(Light *l)
Definition light.h:109
mat4 m_dir_proj
Definition light.h:76
float m_shadow_map_proj_size
Definition light.h:74
void set_ambient_light(const vec4 &v)
Definition light.cpp:95
LightAnimation m_ambient_anim
Definition light.h:70
const mat4 & point_proj() const
Definition light.h:97
bool zsprites(void) const
Definition light.h:83
LightsUBO m_ubo
Definition light.h:78
#define NNGN_SHADOWS_ENABLED_BIT
Definition const.h:7
#define NNGN_MAX_LIGHTS
Definition const.h:6
for i
Definition font.lua:5
local c
Definition gamma.lua:11
local r
Definition gamma.lua:7
update
Definition img_common.lua:42
pos
Definition lua_audio.cpp:17
local l
Definition light.lua:23
vec4_base< float > vec4
Definition vec4.h:128
v[1]
Definition math.lua:22
Wrapper for a small unsigned integral representing flags.
Definition flags.h:18
constexpr bool is_set(AT a) const
Definition flags.h:45
void set_cutoff(float v)
Definition light.cpp:23
static constexpr vec3 att_for_range(float r)
Definition light.h:34
mat4 ortho_view(float far) const
Definition light.cpp:40
float range() const
Definition light.h:44
void set_att(lua_State *L)
Definition light.cpp:26
void write_to_ubo_dir(LightsUBO *ubo, size_t i, float far, const mat4 &proj) const
Definition light.cpp:59
void write_to_ubo_point(LightsUBO *ubo, size_t i, bool zsprites) const
Definition light.cpp:66
Type type
Definition light.h:27
Type
Definition light.h:26
@ DIR
Definition light.h:26
@ POINT
Definition light.h:26
bool updated
Definition light.h:33
float spec
Definition light.h:32
Entity * e
Definition light.h:28
void set_color(const vec4 &c)
Definition light.cpp:19
vec3 att
Definition light.h:31
constexpr Light(Type t) noexcept
Definition light.h:37
vec3 dir
Definition light.h:29
void set_spec(float v)
Definition light.cpp:21
vec3 ortho_view_pos(float far) const
Definition light.cpp:36
float cutoff
Definition light.h:32
vec4 color
Definition light.h:30
constexpr Light()=default
mat4 persp_view(int face, bool zsprites) const
Definition light.cpp:44
void set_pos(const vec3 &p)
Definition light.cpp:15
void set_dir(const vec3 &p)
Definition light.cpp:17
Definition graphics.h:114
std::chrono::seconds s
Definition timing.cpp:6