Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ShadowRenderer Class Reference

#include <dynamicshadowsrender.h>

+ Collaboration diagram for ShadowRenderer:

Public Member Functions

 ShadowRenderer (IrrlichtDevice *device, Client *client)
 
 ~ShadowRenderer ()
 
void initialize ()
 
size_t addDirectionalLight ()
 Adds a directional light shadow map (Usually just one (the sun) except in Tattoine ).
 
DirectionalLightgetDirectionalLight (u32 index=0)
 
size_t getDirectionalLightCount () const
 
f32 getMaxShadowFar () const
 
void addNodeToShadowList (scene::ISceneNode *node, E_SHADOW_MODE shadowMode=ESM_BOTH)
 Adds a shadow to the scene node.
 
void removeNodeFromShadowList (scene::ISceneNode *node)
 
void update (video::ITexture *outputTarget=nullptr)
 
void setForceUpdateShadowMap ()
 
void drawDebug ()
 
video::ITexture * get_texture ()
 
bool is_active () const
 
void setTimeOfDay (float isDay)
 
void setShadowIntensity (float shadow_intensity)
 
void setShadowTint (video::SColor shadow_tint)
 
s32 getShadowSamples () const
 
float getShadowStrength () const
 
video::SColor getShadowTint () const
 
float getTimeOfDay () const
 
f32 getPerspectiveBiasXY ()
 
f32 getPerspectiveBiasZ ()
 

Static Public Member Functions

static void preInit (IWritableShaderSource *shsrc)
 

Static Public Attributes

static const int TEXTURE_LAYER_SHADOW = 3
 

Private Member Functions

video::ITexture * getSMTexture (const std::string &shadow_map_name, video::ECOLOR_FORMAT texture_format, bool force_creation=false)
 
void renderShadowMap (video::ITexture *target, DirectionalLight &light, scene::E_SCENE_NODE_RENDER_PASS pass=scene::ESNRP_SOLID)
 
void renderShadowObjects (video::ITexture *target, DirectionalLight &light)
 
void mixShadowsQuad ()
 
void updateSMTextures ()
 
void disable ()
 
void enable ()
 
void createShaders ()
 
std::string readShaderFile (const std::string &path)
 

Private Attributes

scene::ISceneManager * m_smgr {nullptr}
 
video::IVideoDriver * m_driver {nullptr}
 
Clientm_client {nullptr}
 
video::ITexture * shadowMapClientMap {nullptr}
 
video::ITexture * shadowMapClientMapFuture {nullptr}
 
video::ITexture * shadowMapTextureFinal {nullptr}
 
video::ITexture * shadowMapTextureDynamicObjects {nullptr}
 
video::ITexture * shadowMapTextureColors {nullptr}
 
std::vector< DirectionalLightm_light_list
 
std::vector< NodeToApplym_shadow_node_array
 
float m_shadow_strength
 
video::SColor m_shadow_tint { 255, 0, 0, 0 }
 
float m_shadow_strength_gamma
 
float m_shadow_map_max_distance
 
float m_shadow_map_texture_size
 
float m_time_day {0.0f}
 
int m_shadow_samples
 
bool m_shadow_map_texture_32bit
 
bool m_shadows_enabled
 
bool m_shadows_supported
 
bool m_shadow_map_colored
 
bool m_force_update_shadow_map
 
u8 m_map_shadow_update_frames
 
u8 m_current_frame {0}
 
f32 m_perspective_bias_xy
 
f32 m_perspective_bias_z
 
video::ECOLOR_FORMAT m_texture_format {video::ECOLOR_FORMAT::ECF_R16F}
 
video::ECOLOR_FORMAT m_texture_format_color {video::ECOLOR_FORMAT::ECF_R16G16}
 
s32 depth_shader {-1}
 
s32 depth_shader_entities {-1}
 
s32 depth_shader_trans {-1}
 
s32 mixcsm_shader {-1}
 
ShadowDepthShaderCBm_shadow_depth_cb {nullptr}
 
ShadowDepthShaderCBm_shadow_depth_entity_cb {nullptr}
 
ShadowDepthShaderCBm_shadow_depth_trans_cb {nullptr}
 
shadowScreenQuadm_screen_quad {nullptr}
 
shadowScreenQuadCBm_shadow_mix_cb {nullptr}
 

Constructor & Destructor Documentation

◆ ShadowRenderer()

ShadowRenderer::ShadowRenderer ( IrrlichtDevice * device,
Client * client )

◆ ~ShadowRenderer()

ShadowRenderer::~ShadowRenderer ( )

References disable(), m_light_list, m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb, m_shadow_mix_cb, and m_shadow_node_array.

+ Here is the call graph for this function:

Member Function Documentation

◆ addDirectionalLight()

size_t ShadowRenderer::addDirectionalLight ( )

Adds a directional light shadow map (Usually just one (the sun) except in Tattoine ).

References m_light_list, m_shadow_map_max_distance, and m_shadow_map_texture_size.

Referenced by ShadowRenderer().

+ Here is the caller graph for this function:

◆ addNodeToShadowList()

void ShadowRenderer::addNodeToShadowList ( scene::ISceneNode * node,
E_SHADOW_MODE shadowMode = ESM_BOTH )

Adds a shadow to the scene node.

The shadow mode can be ESM_BOTH, or ESM_RECEIVE. ESM_BOTH casts and receives shadows ESM_RECEIVE only receives but does not cast shadows.

References m_shadow_node_array, shadowMapTextureFinal, and TEXTURE_LAYER_SHADOW.

Referenced by WieldMeshSceneNode::WieldMeshSceneNode().

+ Here is the caller graph for this function:

◆ createShaders()

void ShadowRenderer::createShaders ( )
private

References depth_shader, depth_shader_entities, depth_shader_trans, errorstream, shadowScreenQuad::getMaterial(), getShaderPath(), m_driver, m_screen_quad, m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb, m_shadow_map_colored, m_shadow_mix_cb, m_shadows_enabled, m_shadows_supported, mixcsm_shader, and readShaderFile().

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disable()

void ShadowRenderer::disable ( )
private

References m_driver, m_shadow_node_array, m_shadows_enabled, shadowMapClientMap, shadowMapClientMapFuture, shadowMapTextureColors, shadowMapTextureDynamicObjects, shadowMapTextureFinal, and TEXTURE_LAYER_SHADOW.

Referenced by ~ShadowRenderer(), and setShadowIntensity().

+ Here is the caller graph for this function:

◆ drawDebug()

void ShadowRenderer::drawDebug ( )

References m_driver, m_shadow_map_colored, shadowMapClientMap, shadowMapTextureColors, shadowMapTextureDynamicObjects, and shadowMapTextureFinal.

Referenced by DrawHUD::run().

+ Here is the caller graph for this function:

◆ enable()

void ShadowRenderer::enable ( )
inlineprivate

References m_shadows_enabled, and m_shadows_supported.

Referenced by setShadowIntensity().

+ Here is the caller graph for this function:

◆ get_texture()

video::ITexture * ShadowRenderer::get_texture ( )
inline

References shadowMapTextureFinal.

Referenced by ClientMap::renderMap().

+ Here is the caller graph for this function:

◆ getDirectionalLight()

DirectionalLight & ShadowRenderer::getDirectionalLight ( u32 index = 0)

References m_light_list.

Referenced by Game::updateShadows().

+ Here is the caller graph for this function:

◆ getDirectionalLightCount()

size_t ShadowRenderer::getDirectionalLightCount ( ) const

References m_light_list.

◆ getMaxShadowFar()

f32 ShadowRenderer::getMaxShadowFar ( ) const

References m_light_list.

◆ getPerspectiveBiasXY()

f32 ShadowRenderer::getPerspectiveBiasXY ( )
inline

References m_perspective_bias_xy.

Referenced by updateSMTextures().

+ Here is the caller graph for this function:

◆ getPerspectiveBiasZ()

f32 ShadowRenderer::getPerspectiveBiasZ ( )
inline

References m_perspective_bias_z.

Referenced by updateSMTextures().

+ Here is the caller graph for this function:

◆ getShadowSamples()

s32 ShadowRenderer::getShadowSamples ( ) const
inline

References m_shadow_samples.

◆ getShadowStrength()

float ShadowRenderer::getShadowStrength ( ) const
inline

◆ getShadowTint()

video::SColor ShadowRenderer::getShadowTint ( ) const
inline

References m_shadow_tint.

◆ getSMTexture()

video::ITexture * ShadowRenderer::getSMTexture ( const std::string & shadow_map_name,
video::ECOLOR_FORMAT texture_format,
bool force_creation = false )
private

References m_driver, and m_shadow_map_texture_size.

Referenced by updateSMTextures().

+ Here is the caller graph for this function:

◆ getTimeOfDay()

float ShadowRenderer::getTimeOfDay ( ) const
inline

References m_time_day.

◆ initialize()

void ShadowRenderer::initialize ( )

References createShaders(), m_driver, m_shadow_map_texture_32bit, m_shadows_enabled, m_shadows_supported, m_texture_format, m_texture_format_color, and warningstream.

Referenced by createShadowRenderer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_active()

bool ShadowRenderer::is_active ( ) const
inline

References m_shadows_enabled, and shadowMapTextureFinal.

Referenced by ClientMap::renderMap().

+ Here is the caller graph for this function:

◆ mixShadowsQuad()

void ShadowRenderer::mixShadowsQuad ( )
private

◆ preInit()

void ShadowRenderer::preInit ( IWritableShaderSource * shsrc)
static

References IWritableShaderSource::addShaderConstantSetterFactory(), g_settings, and Settings::getBool().

Referenced by Game::createClient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readShaderFile()

std::string ShadowRenderer::readShaderFile ( const std::string & path)
private

References m_shadow_map_colored, and fs::ReadFile().

Referenced by createShaders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeNodeFromShadowList()

void ShadowRenderer::removeNodeFromShadowList ( scene::ISceneNode * node)

References m_shadow_node_array, and TEXTURE_LAYER_SHADOW.

Referenced by WieldMeshSceneNode::~WieldMeshSceneNode().

+ Here is the caller graph for this function:

◆ renderShadowMap()

void ShadowRenderer::renderShadowMap ( video::ITexture * target,
DirectionalLight & light,
scene::E_SCENE_NODE_RENDER_PASS pass = scene::ESNRP_SOLID )
private

References depth_shader, depth_shader_trans, Client::getEnv(), DirectionalLight::getFutureProjectionMatrix(), DirectionalLight::getFutureViewMatrix(), ClientEnvironment::getMap(), m_client, m_current_frame, m_driver, m_force_update_shadow_map, m_map_shadow_update_frames, m_shadow_map_colored, and ClientMap::renderMapShadows().

Referenced by updateSMTextures().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderShadowObjects()

void ShadowRenderer::renderShadowObjects ( video::ITexture * target,
DirectionalLight & light )
private

References depth_shader_entities, ESM_RECEIVE, DirectionalLight::getProjectionMatrix(), DirectionalLight::getViewMatrix(), m_driver, and m_shadow_node_array.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setForceUpdateShadowMap()

void ShadowRenderer::setForceUpdateShadowMap ( )
inline

◆ setShadowIntensity()

void ShadowRenderer::setShadowIntensity ( float shadow_intensity)

References disable(), enable(), m_shadow_strength, and m_shadow_strength_gamma.

Referenced by Game::updateShadows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setShadowTint()

void ShadowRenderer::setShadowTint ( video::SColor shadow_tint)
inline

References m_shadow_tint.

Referenced by Game::updateShadows().

+ Here is the caller graph for this function:

◆ setTimeOfDay()

void ShadowRenderer::setTimeOfDay ( float isDay)
inline

References m_time_day.

Referenced by Game::updateShadows().

+ Here is the caller graph for this function:

◆ update()

void ShadowRenderer::update ( video::ITexture * outputTarget = nullptr)

References ShadowDepthShaderCB::CameraPos, shadowScreenQuad::getMaterial(), m_driver, m_light_list, m_screen_quad, m_shadow_depth_entity_cb, m_shadow_map_colored, m_shadow_node_array, m_shadows_enabled, m_smgr, shadowScreenQuad::render(), renderShadowObjects(), shadowMapClientMap, shadowMapTextureColors, shadowMapTextureDynamicObjects, shadowMapTextureFinal, and updateSMTextures().

Referenced by RenderShadowMapStep::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSMTextures()

void ShadowRenderer::updateSMTextures ( )
private

References BS, getPerspectiveBiasXY(), getPerspectiveBiasZ(), getSMTexture(), itos(), m_current_frame, m_driver, m_force_update_shadow_map, m_light_list, m_map_shadow_update_frames, m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb, m_shadow_map_colored, m_shadow_map_max_distance, m_shadow_map_texture_32bit, m_shadow_map_texture_size, m_shadow_node_array, m_shadows_enabled, m_smgr, m_texture_format, m_texture_format_color, renderShadowMap(), shadowMapClientMap, shadowMapClientMapFuture, shadowMapTextureColors, shadowMapTextureDynamicObjects, shadowMapTextureFinal, and TEXTURE_LAYER_SHADOW.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ depth_shader

s32 ShadowRenderer::depth_shader {-1}
private

Referenced by createShaders(), and renderShadowMap().

◆ depth_shader_entities

s32 ShadowRenderer::depth_shader_entities {-1}
private

◆ depth_shader_trans

s32 ShadowRenderer::depth_shader_trans {-1}
private

Referenced by createShaders(), and renderShadowMap().

◆ m_client

Client* ShadowRenderer::m_client {nullptr}
private

Referenced by ShadowRenderer(), and renderShadowMap().

◆ m_current_frame

u8 ShadowRenderer::m_current_frame {0}
private

◆ m_driver

video::IVideoDriver* ShadowRenderer::m_driver {nullptr}
private

◆ m_force_update_shadow_map

bool ShadowRenderer::m_force_update_shadow_map
private

◆ m_light_list

◆ m_map_shadow_update_frames

u8 ShadowRenderer::m_map_shadow_update_frames
private

◆ m_perspective_bias_xy

f32 ShadowRenderer::m_perspective_bias_xy
private

Referenced by getPerspectiveBiasXY().

◆ m_perspective_bias_z

f32 ShadowRenderer::m_perspective_bias_z
private

Referenced by getPerspectiveBiasZ().

◆ m_screen_quad

shadowScreenQuad* ShadowRenderer::m_screen_quad {nullptr}
private

Referenced by createShaders(), and update().

◆ m_shadow_depth_cb

ShadowDepthShaderCB* ShadowRenderer::m_shadow_depth_cb {nullptr}
private

◆ m_shadow_depth_entity_cb

ShadowDepthShaderCB* ShadowRenderer::m_shadow_depth_entity_cb {nullptr}
private

◆ m_shadow_depth_trans_cb

ShadowDepthShaderCB* ShadowRenderer::m_shadow_depth_trans_cb {nullptr}
private

◆ m_shadow_map_colored

bool ShadowRenderer::m_shadow_map_colored
private

◆ m_shadow_map_max_distance

float ShadowRenderer::m_shadow_map_max_distance
private

◆ m_shadow_map_texture_32bit

bool ShadowRenderer::m_shadow_map_texture_32bit
private

◆ m_shadow_map_texture_size

float ShadowRenderer::m_shadow_map_texture_size
private

◆ m_shadow_mix_cb

shadowScreenQuadCB* ShadowRenderer::m_shadow_mix_cb {nullptr}
private

Referenced by ~ShadowRenderer(), and createShaders().

◆ m_shadow_node_array

std::vector<NodeToApply> ShadowRenderer::m_shadow_node_array
private

◆ m_shadow_samples

int ShadowRenderer::m_shadow_samples
private

Referenced by ShadowRenderer(), and getShadowSamples().

◆ m_shadow_strength

float ShadowRenderer::m_shadow_strength
private

◆ m_shadow_strength_gamma

float ShadowRenderer::m_shadow_strength_gamma
private

◆ m_shadow_tint

video::SColor ShadowRenderer::m_shadow_tint { 255, 0, 0, 0 }
private

Referenced by getShadowTint(), and setShadowTint().

◆ m_shadows_enabled

bool ShadowRenderer::m_shadows_enabled
private

◆ m_shadows_supported

bool ShadowRenderer::m_shadows_supported
private

◆ m_smgr

scene::ISceneManager* ShadowRenderer::m_smgr {nullptr}
private

Referenced by update(), and updateSMTextures().

◆ m_texture_format

video::ECOLOR_FORMAT ShadowRenderer::m_texture_format {video::ECOLOR_FORMAT::ECF_R16F}
private

Referenced by initialize(), and updateSMTextures().

◆ m_texture_format_color

video::ECOLOR_FORMAT ShadowRenderer::m_texture_format_color {video::ECOLOR_FORMAT::ECF_R16G16}
private

Referenced by initialize(), and updateSMTextures().

◆ m_time_day

float ShadowRenderer::m_time_day {0.0f}
private

Referenced by getTimeOfDay(), and setTimeOfDay().

◆ mixcsm_shader

s32 ShadowRenderer::mixcsm_shader {-1}
private

Referenced by createShaders().

◆ shadowMapClientMap

video::ITexture* ShadowRenderer::shadowMapClientMap {nullptr}
private

◆ shadowMapClientMapFuture

video::ITexture* ShadowRenderer::shadowMapClientMapFuture {nullptr}
private

Referenced by disable(), and updateSMTextures().

◆ shadowMapTextureColors

video::ITexture* ShadowRenderer::shadowMapTextureColors {nullptr}
private

◆ shadowMapTextureDynamicObjects

video::ITexture* ShadowRenderer::shadowMapTextureDynamicObjects {nullptr}
private

◆ shadowMapTextureFinal

video::ITexture* ShadowRenderer::shadowMapTextureFinal {nullptr}
private

◆ TEXTURE_LAYER_SHADOW


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