nngn
Loading...
Searching...
No Matches
nngn::Lighting Class Reference

#include <light.h>

Collaboration diagram for nngn::Lighting:

Public Member Functions

void init (Math *m)
 
bool enabled () const
 
bool zsprites (void) const
 
bool update_sun (void) const
 
bool shadows_enabled (void) const
 
const vec4ambient_light () const
 
std::span< const Lightdir_lights () const
 
std::span< Lightdir_lights ()
 
std::span< const Lightpoint_lights () const
 
std::span< Lightpoint_lights ()
 
Lightsun_light ()
 
const Lightsun_light () const
 
float shadow_map_near () const
 
float shadow_map_far () const
 
const mat4dir_proj () const
 
const mat4point_proj () const
 
const mat4dir_view (size_t i) const
 
const mat4point_view (size_t i, size_t f) const
 
const LightsUBOubo () const
 
Sunsun ()
 
void set_enabled (bool b)
 
void set_zsprites (bool b)
 
void set_update_sun (bool b)
 
void set_shadows_enabled (bool b)
 
void set_ambient_light (const vec4 &v)
 
void set_ambient_anim (LightAnimation a)
 
void set_sun_light (Light *l)
 
void set_shadow_map_proj_size (float s)
 
void set_shadow_map_near (float f)
 
void set_shadow_map_far (float f)
 
Lightadd_light (Light::Type t)
 
void remove_light (Light *l)
 
bool update (const Timing &t)
 
void update_view (const vec3 &eye)
 

Static Public Attributes

static constexpr size_t MAX_LIGHTS = NNGN_MAX_LIGHTS
 

Private Types

enum  Flag : uint8_t {
  ENABLED = 1u << 0 , SHADOWS_ENABLED = NNGN_SHADOWS_ENABLED_BIT , ZSPRITES = 1u << 2 , UPDATE_SUN = 1u << 3 ,
  UPDATED = 1u << 4 , VIEW_UPDATED = 1u << 5 , SHADOW_MAPS_UPDATED = 1u << 6
}
 

Private Attributes

Mathmath = nullptr
 
Flags< Flagflags = {Flag::ENABLED | Flag::UPDATE_SUN | Flag::UPDATED}
 
vec3 view_pos = {}
 
vec4 m_ambient_light = vec4(1)
 
LightAnimation m_ambient_anim = {}
 
size_t n_dir = 0
 
size_t n_point = 0
 
std::array< Light, MAX_LIGHTSm_dir_lights = {}
 
std::array< Light, MAX_LIGHTSm_point_lights = {}
 
Lightm_sun_light = nullptr
 
float m_shadow_map_proj_size = 128.0f
 
float m_shadow_map_near = 1.0f
 
float m_shadow_map_far = 1024.0f
 
mat4 m_dir_proj = {}
 
mat4 m_point_proj = {}
 
std::array< mat4, 7 *MAX_LIGHTSviews = {}
 
LightsUBO m_ubo = {}
 
Sun m_sun = {}
 

Member Enumeration Documentation

◆ Flag

enum nngn::Lighting::Flag : uint8_t
private
Enumerator
ENABLED 
SHADOWS_ENABLED 
ZSPRITES 
UPDATE_SUN 
UPDATED 
VIEW_UPDATED 
SHADOW_MAPS_UPDATED 

Member Function Documentation

◆ add_light()

Light * nngn::Lighting::add_light ( Light::Type t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ambient_light()

const vec4 & nngn::Lighting::ambient_light ( ) const
inline

◆ dir_lights() [1/2]

std::span< Light > nngn::Lighting::dir_lights ( )
inline

◆ dir_lights() [2/2]

std::span< const Light > nngn::Lighting::dir_lights ( ) const
inline

◆ dir_proj()

const mat4 & nngn::Lighting::dir_proj ( ) const
inline

◆ dir_view()

const mat4 & nngn::Lighting::dir_view ( size_t i) const
inline

◆ enabled()

bool nngn::Lighting::enabled ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void nngn::Lighting::init ( Math * m)
inline
Here is the caller graph for this function:

◆ point_lights() [1/2]

std::span< Light > nngn::Lighting::point_lights ( )
inline

◆ point_lights() [2/2]

std::span< const Light > nngn::Lighting::point_lights ( ) const
inline

◆ point_proj()

const mat4 & nngn::Lighting::point_proj ( ) const
inline

◆ point_view()

const mat4 & nngn::Lighting::point_view ( size_t i,
size_t f ) const
inline
Here is the call graph for this function:

◆ remove_light()

void nngn::Lighting::remove_light ( Light * l)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_ambient_anim()

void nngn::Lighting::set_ambient_anim ( LightAnimation a)

◆ set_ambient_light()

void nngn::Lighting::set_ambient_light ( const vec4 & v)

◆ set_enabled()

void nngn::Lighting::set_enabled ( bool b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_shadow_map_far()

void nngn::Lighting::set_shadow_map_far ( float f)
Here is the call graph for this function:

◆ set_shadow_map_near()

void nngn::Lighting::set_shadow_map_near ( float f)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_shadow_map_proj_size()

void nngn::Lighting::set_shadow_map_proj_size ( float s)
Here is the caller graph for this function:

◆ set_shadows_enabled()

void nngn::Lighting::set_shadows_enabled ( bool b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_sun_light()

void nngn::Lighting::set_sun_light ( Light * l)
inline
Here is the caller graph for this function:

◆ set_update_sun()

void nngn::Lighting::set_update_sun ( bool b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_zsprites()

void nngn::Lighting::set_zsprites ( bool b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shadow_map_far()

float nngn::Lighting::shadow_map_far ( ) const
inline

◆ shadow_map_near()

float nngn::Lighting::shadow_map_near ( ) const
inline

◆ shadows_enabled()

bool nngn::Lighting::shadows_enabled ( void ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sun()

Sun * nngn::Lighting::sun ( )
inline
Here is the caller graph for this function:

◆ sun_light() [1/2]

Light * nngn::Lighting::sun_light ( )
inline

◆ sun_light() [2/2]

const Light * nngn::Lighting::sun_light ( ) const
inline

◆ ubo()

const LightsUBO & nngn::Lighting::ubo ( ) const
inline

◆ update()

bool nngn::Lighting::update ( const Timing & t)
Here is the call graph for this function:

◆ update_sun()

bool nngn::Lighting::update_sun ( void ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_view()

void nngn::Lighting::update_view ( const vec3 & eye)

◆ zsprites()

bool nngn::Lighting::zsprites ( void ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ flags

Flags<Flag> nngn::Lighting::flags = {Flag::ENABLED | Flag::UPDATE_SUN | Flag::UPDATED}
private

◆ m_ambient_anim

LightAnimation nngn::Lighting::m_ambient_anim = {}
private

◆ m_ambient_light

vec4 nngn::Lighting::m_ambient_light = vec4(1)
private

◆ m_dir_lights

std::array<Light, MAX_LIGHTS> nngn::Lighting::m_dir_lights = {}
private

◆ m_dir_proj

mat4 nngn::Lighting::m_dir_proj = {}
private

◆ m_point_lights

std::array<Light, MAX_LIGHTS> nngn::Lighting::m_point_lights = {}
private

◆ m_point_proj

mat4 nngn::Lighting::m_point_proj = {}
private

◆ m_shadow_map_far

float nngn::Lighting::m_shadow_map_far = 1024.0f
private

◆ m_shadow_map_near

float nngn::Lighting::m_shadow_map_near = 1.0f
private

◆ m_shadow_map_proj_size

float nngn::Lighting::m_shadow_map_proj_size = 128.0f
private

◆ m_sun

Sun nngn::Lighting::m_sun = {}
private

◆ m_sun_light

Light* nngn::Lighting::m_sun_light = nullptr
private

◆ m_ubo

LightsUBO nngn::Lighting::m_ubo = {}
private

◆ math

Math* nngn::Lighting::math = nullptr
private

◆ MAX_LIGHTS

size_t nngn::Lighting::MAX_LIGHTS = NNGN_MAX_LIGHTS
staticconstexpr

◆ n_dir

size_t nngn::Lighting::n_dir = 0
private

◆ n_point

size_t nngn::Lighting::n_point = 0
private

◆ view_pos

vec3 nngn::Lighting::view_pos = {}
private

◆ views

std::array<mat4, 7 * MAX_LIGHTS> nngn::Lighting::views = {}
private

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