Antkeeper  0.0.1
Public Member Functions | List of all members
scene::directional_light Class Reference

Light source with parallel rays and constant intensity. More...

#include <directional-light.hpp>

Inheritance diagram for scene::directional_light:
scene::light scene::object< light > scene::object_base

Public Member Functions

 directional_light ()
 Creates a directional light. More...
 
light_type get_light_type () const noexcept override
 Returns light_type::directional. More...
 
constexpr std::span< const math::fmat4get_shadow_scale_bias_matrices () const noexcept
 Returns the array of shadow cascade scale-bias matrices. More...
 
Light
void set_direction (const math::fvec3 &direction)
 Sets the direction of the directional light. More...
 
void set_color (const math::fvec3 &color) noexcept
 Sets the color of the light. More...
 
void set_illuminance (float illuminance) noexcept
 Sets the illuminance of the light on a surface perpendicular to the light direction. More...
 
constexpr const math::fvec3get_direction () const noexcept
 Returns a unit vector pointing in the light direction. More...
 
constexpr const math::fvec3get_color () const noexcept
 Returns the color of the light. More...
 
constexpr float get_illuminance () const noexcept
 Returns the illuminance of the light on a surface perpendicular to the light direction. More...
 
constexpr const math::fvec3get_colored_illuminance () const noexcept
 Returns the color-modulated illuminance of the light on a surface perpendicular to the light direction. More...
 
Shadow
void set_shadow_caster (bool caster) noexcept
 Enables or disables shadow casting. More...
 
void set_shadow_framebuffer (std::shared_ptr< gl::framebuffer > framebuffer) noexcept
 Sets the shadow map framebuffer. More...
 
void set_shadow_bias (float bias) noexcept
 Sets the shadow bias factor for reducing self-shadowing. More...
 
void set_shadow_cascade_count (unsigned int count) noexcept
 Sets the number of shadow cascades. More...
 
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. More...
 
void set_shadow_fade_range (float range) noexcept
 Sets the distance from the maximum shadow distance at which shadows will begin to fade out. More...
 
void set_shadow_cascade_distribution (float weight) noexcept
 Sets the shadow cascade distribution. More...
 
constexpr bool is_shadow_caster () const noexcept
 Returns true if the light casts shadows, false otherwise. More...
 
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. More...
 
constexpr const std::shared_ptr< gl::texture_2d > & get_shadow_texture () const noexcept
 Returns the shadow map texture. More...
 
constexpr float get_shadow_bias () const noexcept
 Returns the shadow bias factor. More...
 
constexpr unsigned int get_shadow_cascade_count () const noexcept
 Returns the number of shadow cascades. More...
 
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. More...
 
constexpr float get_shadow_fade_range () const noexcept
 Returns the distance from the maximum shadow distance at which shadows will begin to fade out. More...
 
constexpr float get_shadow_cascade_distribution () const noexcept
 Returns the shadow cascade distribution weight. More...
 
constexpr const math::fvec4get_shadow_cascade_distances () const noexcept
 Returns the array of shadow cascade far clipping plane distances. More...
 
constexpr math::fvec4get_shadow_cascade_distances () noexcept
 Enables or disables shadow casting. More...
 
constexpr std::span< const math::fmat4get_shadow_cascade_matrices () const noexcept
 Returns the array of world-space to cascade texture-space transformation matrices. More...
 
constexpr std::span< math::fmat4get_shadow_cascade_matrices () noexcept
 Returns the array of world-space to cascade texture-space transformation matrices. More...
 
- Public Member Functions inherited from scene::light
const aabb_typeget_bounds () const noexcept override
 Returns the bounds of the object. More...
 
void set_color (const math::fvec3 &color)
 Sets the color of the light. More...
 
void set_color_temperature (float temperature)
 Sets the color of the light from a color temperature. More...
 
constexpr const math::fvec3get_color () const noexcept
 Returns the scene-linear RGB color of the light. More...
 
- Public Member Functions inherited from scene::object< light >
const std::size_t get_object_type_id () const noexcept final
 Returns the type ID for this scene object type. More...
 
- Public Member Functions inherited from scene::object_base
virtual void render (render::context &ctx) const
 Adds render operations to a render context. More...
 
void look_at (const vector_type &position, const vector_type &target, const vector_type &up)
 
constexpr void set_layer_mask (std::uint32_t mask) noexcept
 Sets the layer mask of the object. More...
 
void set_transform (const transform_type &transform)
 Sets the transform of the object. More...
 
void set_translation (const vector_type &translation)
 Sets the translation of the object. More...
 
void set_rotation (const quaternion_type &rotation)
 Sets the rotation of the object. More...
 
constexpr std::uint32_t get_layer_mask () const noexcept
 Returns the layer mask of the object. More...
 
constexpr const transform_typeget_transform () const noexcept
 Returns the transform of the object. More...
 
constexpr const vector_typeget_translation () const noexcept
 Returns the translation of the object. More...
 
constexpr const quaternion_typeget_rotation () const noexcept
 Returns the rotation of the object. More...
 
constexpr const vector_typeget_scale () const noexcept
 Returns the scale of the object. More...
 
void set_scale (const vector_type &scale)
 Sets the scale of the object. More...
 
void set_scale (float scale)
 Sets the scale of the object. More...
 

Additional Inherited Members

- Public Types inherited from scene::object_base
using vector_type = math::fvec3
 
using quaternion_type = math::fquat
 
using transform_type = math::transform< float >
 
using aabb_type = geom::box< float >
 
- Static Public Attributes inherited from scene::object< light >
static const std::atomic< std::size_t > object_type_id
 Unique type ID for this scene object type. More...
 
- Static Protected Member Functions inherited from scene::object_base
static std::size_t next_object_type_id ()
 
- Protected Attributes inherited from scene::object_base
std::uint32_t m_layer_mask {1}
 
transform_type m_transform {transform_type::identity()}
 

Detailed Description

Light source with parallel rays and constant intensity.

Definition at line 34 of file directional-light.hpp.

Constructor & Destructor Documentation

◆ directional_light()

scene::directional_light::directional_light ( )

Creates a directional light.

Definition at line 26 of file directional-light.cpp.

Member Function Documentation

◆ get_color()

constexpr const math::fvec3& scene::directional_light::get_color ( ) const
inlineconstexprnoexcept

Returns the color of the light.

Definition at line 85 of file directional-light.hpp.

◆ get_colored_illuminance()

constexpr const math::fvec3& scene::directional_light::get_colored_illuminance ( ) const
inlineconstexprnoexcept

Returns the color-modulated illuminance of the light on a surface perpendicular to the light direction.

Definition at line 97 of file directional-light.hpp.

◆ get_direction()

constexpr const math::fvec3& scene::directional_light::get_direction ( ) const
inlineconstexprnoexcept

Returns a unit vector pointing in the light direction.

Definition at line 79 of file directional-light.hpp.

◆ get_illuminance()

constexpr float scene::directional_light::get_illuminance ( ) const
inlineconstexprnoexcept

Returns the illuminance of the light on a surface perpendicular to the light direction.

Definition at line 91 of file directional-light.hpp.

◆ get_light_type()

light_type scene::directional_light::get_light_type ( ) const
inlineoverridevirtualnoexcept

Returns light_type::directional.

Implements scene::light.

Definition at line 41 of file directional-light.hpp.

◆ get_shadow_bias()

constexpr float scene::directional_light::get_shadow_bias ( ) const
inlineconstexprnoexcept

Returns the shadow bias factor.

Definition at line 177 of file directional-light.hpp.

◆ get_shadow_cascade_count()

constexpr unsigned int scene::directional_light::get_shadow_cascade_count ( ) const
inlineconstexprnoexcept

Returns the number of shadow cascades.

Definition at line 183 of file directional-light.hpp.

◆ get_shadow_cascade_distances() [1/2]

constexpr const math::fvec4& scene::directional_light::get_shadow_cascade_distances ( ) const
inlineconstexprnoexcept

Returns the array of shadow cascade far clipping plane distances.

Definition at line 208 of file directional-light.hpp.

◆ get_shadow_cascade_distances() [2/2]

constexpr math::fvec4& scene::directional_light::get_shadow_cascade_distances ( )
inlineconstexprnoexcept

Enables or disables shadow casting.

Parameters
castertrue if the light should cast shadows, false otherwise.

Definition at line 212 of file directional-light.hpp.

◆ get_shadow_cascade_distribution()

constexpr float scene::directional_light::get_shadow_cascade_distribution ( ) const
inlineconstexprnoexcept

Returns the shadow cascade distribution weight.

Definition at line 201 of file directional-light.hpp.

◆ get_shadow_cascade_matrices() [1/2]

constexpr std::span<const math::fmat4> scene::directional_light::get_shadow_cascade_matrices ( ) const
inlineconstexprnoexcept

Returns the array of world-space to cascade texture-space transformation matrices.

Definition at line 226 of file directional-light.hpp.

◆ get_shadow_cascade_matrices() [2/2]

constexpr std::span<math::fmat4> scene::directional_light::get_shadow_cascade_matrices ( )
inlineconstexprnoexcept

Returns the array of world-space to cascade texture-space transformation matrices.

Definition at line 230 of file directional-light.hpp.

◆ get_shadow_fade_range()

constexpr float scene::directional_light::get_shadow_fade_range ( ) const
inlineconstexprnoexcept

Returns the distance from the maximum shadow distance at which shadows will begin to fade out.

Definition at line 195 of file directional-light.hpp.

◆ get_shadow_framebuffer()

constexpr const std::shared_ptr<gl::framebuffer>& scene::directional_light::get_shadow_framebuffer ( ) const
inlineconstexprnoexcept

Returns the shadow map framebuffer, of nullptr if no shadow map framebuffer is set.

Definition at line 165 of file directional-light.hpp.

◆ get_shadow_max_distance()

constexpr float scene::directional_light::get_shadow_max_distance ( ) const
inlineconstexprnoexcept

Returns the maximum distance from a camera's near clipping plane up to which shadows are visible.

Definition at line 189 of file directional-light.hpp.

◆ get_shadow_scale_bias_matrices()

constexpr std::span<const math::fmat4> scene::directional_light::get_shadow_scale_bias_matrices ( ) const
inlineconstexprnoexcept

Returns the array of shadow cascade scale-bias matrices.

Definition at line 219 of file directional-light.hpp.

◆ get_shadow_texture()

constexpr const std::shared_ptr<gl::texture_2d>& scene::directional_light::get_shadow_texture ( ) const
inlineconstexprnoexcept

Returns the shadow map texture.

Definition at line 171 of file directional-light.hpp.

◆ is_shadow_caster()

constexpr bool scene::directional_light::is_shadow_caster ( ) const
inlineconstexprnoexcept

Returns true if the light casts shadows, false otherwise.

Definition at line 159 of file directional-light.hpp.

◆ set_color()

void scene::directional_light::set_color ( const math::fvec3 color)
inlinenoexcept

Sets the color of the light.

Parameters
colorLight color.

Definition at line 61 of file directional-light.hpp.

◆ set_direction()

void scene::directional_light::set_direction ( const math::fvec3 direction)

Sets the direction of the directional light.

Parameters
directionUnit-length light direction vector.

Definition at line 32 of file directional-light.cpp.

◆ set_illuminance()

void scene::directional_light::set_illuminance ( float  illuminance)
inlinenoexcept

Sets the illuminance of the light on a surface perpendicular to the light direction.

Parameters
illuminanceIlluminance on a surface perpendicular to the light direction.

Definition at line 72 of file directional-light.hpp.

◆ set_shadow_bias()

void scene::directional_light::set_shadow_bias ( float  bias)
noexcept

Sets the shadow bias factor for reducing self-shadowing.

Parameters
biasShadow bias factor.

Definition at line 78 of file directional-light.cpp.

◆ set_shadow_cascade_count()

void scene::directional_light::set_shadow_cascade_count ( unsigned int  count)
noexcept

Sets the number of shadow cascades.

Parameters
countNumber of shadow cascades, on [1, 4].
Note
The number of shadow cascades will be clamped to [1, 4].

Definition at line 84 of file directional-light.cpp.

◆ set_shadow_cascade_distribution()

void scene::directional_light::set_shadow_cascade_distribution ( float  weight)
noexcept

Sets the shadow cascade distribution.

Parameters
weightLinear interpolation weight between uniform and logarithmic cascade distributions. A weight of 0.0 results in a uniform cascade distribution, while 1.0 results in a logarithmic distribution.

Definition at line 102 of file directional-light.cpp.

◆ set_shadow_caster()

void scene::directional_light::set_shadow_caster ( bool  caster)
noexcept

Enables or disables shadow casting.

Parameters
castertrue if the light should cast shadows, false otherwise.

Definition at line 37 of file directional-light.cpp.

◆ set_shadow_fade_range()

void scene::directional_light::set_shadow_fade_range ( float  range)
noexcept

Sets the distance from the maximum shadow distance at which shadows will begin to fade out.

Parameters
rangeShadow fade range.

Definition at line 97 of file directional-light.cpp.

◆ set_shadow_framebuffer()

void scene::directional_light::set_shadow_framebuffer ( std::shared_ptr< gl::framebuffer framebuffer)
noexcept

Sets the shadow map framebuffer.

Parameters
framebufferPointer to a shadow map framebuffer.

Definition at line 42 of file directional-light.cpp.

◆ set_shadow_max_distance()

void scene::directional_light::set_shadow_max_distance ( float  distance)
noexcept

Sets the maximum distance from a camera's near clipping plane up to which shadows are visible.

Parameters
distanceMaximum shadow distance.

Definition at line 91 of file directional-light.cpp.


The documentation for this class was generated from the following files: