Add a default direction light for shadows

This commit is contained in:
Lars 2023-04-06 09:30:37 -10:00 committed by lhofhansl
parent 9d736e8b8b
commit 8982998681
2 changed files with 7 additions and 9 deletions

@ -4212,8 +4212,6 @@ void Game::updateShadows()
v3f sun_pos = light * offset_constant;
if (shadow->getDirectionalLightCount() == 0)
shadow->addDirectionalLight();
shadow->getDirectionalLight().setDirection(sun_pos);
shadow->setTimeOfDay(in_timeofday);

@ -53,6 +53,9 @@ ShadowRenderer::ShadowRenderer(IrrlichtDevice *device, Client *client) :
m_shadow_map_colored = g_settings->getBool("shadow_map_color");
m_shadow_samples = g_settings->getS32("shadow_filters");
m_map_shadow_update_frames = g_settings->getS16("shadow_update_frames");
// add at least one light
addDirectionalLight();
}
ShadowRenderer::~ShadowRenderer()
@ -157,11 +160,8 @@ size_t ShadowRenderer::getDirectionalLightCount() const
f32 ShadowRenderer::getMaxShadowFar() const
{
if (!m_light_list.empty()) {
float zMax = m_light_list[0].getFarValue();
return zMax;
}
return 0.0f;
float zMax = m_light_list[0].getFarValue();
return zMax;
}
void ShadowRenderer::setShadowIntensity(float shadow_intensity)
@ -258,7 +258,7 @@ void ShadowRenderer::updateSMTextures()
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
}
if (!m_shadow_node_array.empty() && !m_light_list.empty()) {
if (!m_shadow_node_array.empty()) {
bool reset_sm_texture = false;
// detect if SM should be regenerated
@ -344,7 +344,7 @@ void ShadowRenderer::update(video::ITexture *outputTarget)
}
if (!m_shadow_node_array.empty() && !m_light_list.empty()) {
if (!m_shadow_node_array.empty()) {
for (DirectionalLight &light : m_light_list) {
// Static shader values for entities are set in updateSMTextures