20 #ifndef ANTKEEPER_SCENE_DIRECTIONAL_LIGHT_HPP
21 #define ANTKEEPER_SCENE_DIRECTIONAL_LIGHT_HPP
74 m_illuminance = illuminance;
75 illuminance_updated();
99 return m_colored_illuminance;
161 return m_shadow_caster;
167 return m_shadow_framebuffer;
171 [[nodiscard]]
inline constexpr
const std::shared_ptr<gl::texture_2d>&
get_shadow_texture() const noexcept
173 return m_shadow_texture;
179 return m_shadow_bias;
185 return m_shadow_cascade_count;
191 return m_shadow_max_distance;
197 return m_shadow_fade_range;
203 return m_shadow_cascade_distribution;
210 return m_shadow_cascade_distances;
214 return m_shadow_cascade_distances;
221 return m_shadow_scale_bias_matrices;
228 return m_shadow_cascade_matrices;
232 return m_shadow_cascade_matrices;
239 void transformed()
override;
240 void color_updated();
241 void illuminance_updated();
242 void update_shadow_scale_bias_matrices();
243 void update_shadow_cascade_distances();
247 float m_illuminance{};
250 bool m_shadow_caster{
false};
251 std::shared_ptr<gl::framebuffer> m_shadow_framebuffer;
252 std::shared_ptr<gl::texture_2d> m_shadow_texture;
253 float m_shadow_bias{0.005f};
254 unsigned int m_shadow_cascade_count{4};
255 float m_shadow_max_distance{100.0f};
256 float m_shadow_fade_range{0.0f};
257 float m_shadow_cascade_distribution{0.8f};
Light source with parallel rays and constant intensity.
void set_shadow_fade_range(float range) noexcept
Sets the distance from the maximum shadow distance at which shadows will begin to fade out.
void set_direction(const math::fvec3 &direction)
Sets the direction of the directional light.
light_type get_light_type() const noexcept override
Returns light_type::directional.
constexpr float get_shadow_fade_range() const noexcept
Returns the distance from the maximum shadow distance at which shadows will begin to fade out.
constexpr bool is_shadow_caster() const noexcept
Returns true if the light casts shadows, false otherwise.
void set_shadow_framebuffer(std::shared_ptr< gl::framebuffer > framebuffer) noexcept
Sets the shadow map framebuffer.
constexpr const std::shared_ptr< gl::framebuffer > & get_shadow_framebuffer() const noexcept
Returns the shadow map framebuffer, of nullptr if no shadow map framebuffer is set.
void set_shadow_cascade_count(unsigned int count) noexcept
Sets the number of shadow cascades.
constexpr const math::fvec3 & get_colored_illuminance() const noexcept
Returns the color-modulated illuminance of the light on a surface perpendicular to the light directio...
void set_shadow_max_distance(float distance) noexcept
Sets the maximum distance from a camera's near clipping plane up to which shadows are visible.
constexpr const math::fvec4 & get_shadow_cascade_distances() const noexcept
Returns the array of shadow cascade far clipping plane distances.
constexpr float get_shadow_bias() const noexcept
Returns the shadow bias factor.
void set_illuminance(float illuminance) noexcept
Sets the illuminance of the light on a surface perpendicular to the light direction.
directional_light()
Creates a directional light.
constexpr const std::shared_ptr< gl::texture_2d > & get_shadow_texture() const noexcept
Returns the shadow map texture.
constexpr float get_shadow_max_distance() const noexcept
Returns the maximum distance from a camera's near clipping plane up to which shadows are visible.
void set_color(const math::fvec3 &color) noexcept
Sets the color of the light.
constexpr const math::fvec3 & get_color() const noexcept
Returns the color of the light.
constexpr std::span< const math::fmat4 > get_shadow_cascade_matrices() const noexcept
Returns the array of world-space to cascade texture-space transformation matrices.
void set_shadow_bias(float bias) noexcept
Sets the shadow bias factor for reducing self-shadowing.
constexpr const math::fvec3 & get_direction() const noexcept
Returns a unit vector pointing in the light direction.
constexpr unsigned int get_shadow_cascade_count() const noexcept
Returns the number of shadow cascades.
constexpr math::fvec4 & get_shadow_cascade_distances() noexcept
Enables or disables shadow casting.
void set_shadow_caster(bool caster) noexcept
Enables or disables shadow casting.
void set_shadow_cascade_distribution(float weight) noexcept
Sets the shadow cascade distribution.
constexpr std::span< math::fmat4 > get_shadow_cascade_matrices() noexcept
Returns the array of world-space to cascade texture-space transformation matrices.
constexpr float get_shadow_cascade_distribution() const noexcept
Returns the shadow cascade distribution weight.
constexpr float get_illuminance() const noexcept
Returns the illuminance of the light on a surface perpendicular to the light direction.
constexpr std::span< const math::fmat4 > get_shadow_scale_bias_matrices() const noexcept
Returns the array of shadow cascade scale-bias matrices.
Abstract base class for light objects.
constexpr int count(T x) noexcept
Returns the number of set bits in a value, known as a population count or Hamming weight.
T distance(const vector< T, N > &p0, const vector< T, N > &p1)
Calculates the distance between two points.
@ color
Vertex color (vec4)
@ directional
Directional light.
n by m column-major matrix.