mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Fix shadow performance regression due to force update
broken by: b861f0c5c5
This commit is contained in:
parent
22c81e5292
commit
eb8b449817
3 changed files with 8 additions and 12 deletions
|
@ -85,6 +85,7 @@ public:
|
||||||
return mapRes;
|
return mapRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, shadow map needs to be invalidated due to frustum change
|
||||||
bool should_update_map_shadow{true};
|
bool should_update_map_shadow{true};
|
||||||
|
|
||||||
void commitFrustum();
|
void commitFrustum();
|
||||||
|
|
|
@ -254,17 +254,14 @@ void ShadowRenderer::updateSMTextures()
|
||||||
if (!m_shadow_node_array.empty()) {
|
if (!m_shadow_node_array.empty()) {
|
||||||
bool reset_sm_texture = false;
|
bool reset_sm_texture = false;
|
||||||
|
|
||||||
// detect if SM should be regenerated
|
// clear texture if requested
|
||||||
for (DirectionalLight &light : m_light_list) {
|
for (DirectionalLight &light : m_light_list) {
|
||||||
if (light.should_update_map_shadow)
|
reset_sm_texture |= light.should_update_map_shadow;
|
||||||
m_force_update_shadow_map = true;
|
|
||||||
light.should_update_map_shadow = false;
|
light.should_update_map_shadow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_force_update_shadow_map) {
|
if (reset_sm_texture || m_force_update_shadow_map)
|
||||||
m_current_frame = 0;
|
m_current_frame = 0;
|
||||||
reset_sm_texture = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
video::ITexture* shadowMapTargetTexture = shadowMapClientMapFuture;
|
video::ITexture* shadowMapTargetTexture = shadowMapClientMapFuture;
|
||||||
if (shadowMapTargetTexture == nullptr)
|
if (shadowMapTargetTexture == nullptr)
|
||||||
|
@ -273,7 +270,7 @@ void ShadowRenderer::updateSMTextures()
|
||||||
// Update SM incrementally:
|
// Update SM incrementally:
|
||||||
for (DirectionalLight &light : m_light_list) {
|
for (DirectionalLight &light : m_light_list) {
|
||||||
// Static shader values.
|
// Static shader values.
|
||||||
for (auto cb : {m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb})
|
for (auto cb : {m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb}) {
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb->MapRes = (f32)m_shadow_map_texture_size;
|
cb->MapRes = (f32)m_shadow_map_texture_size;
|
||||||
cb->MaxFar = (f32)m_shadow_map_max_distance * BS;
|
cb->MaxFar = (f32)m_shadow_map_max_distance * BS;
|
||||||
|
@ -281,12 +278,9 @@ void ShadowRenderer::updateSMTextures()
|
||||||
cb->PerspectiveBiasZ = getPerspectiveBiasZ();
|
cb->PerspectiveBiasZ = getPerspectiveBiasZ();
|
||||||
cb->CameraPos = light.getFuturePlayerPos();
|
cb->CameraPos = light.getFuturePlayerPos();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set the Render Target
|
// Note that force_update means we're drawing everything one go.
|
||||||
// right now we can only render in usual RTT, not
|
|
||||||
// Depth texture is available in irrlicth maybe we
|
|
||||||
// should put some gl* fn here
|
|
||||||
|
|
||||||
|
|
||||||
if (m_current_frame < m_map_shadow_update_frames || m_force_update_shadow_map) {
|
if (m_current_frame < m_map_shadow_update_frames || m_force_update_shadow_map) {
|
||||||
m_driver->setRenderTarget(shadowMapTargetTexture, reset_sm_texture, true,
|
m_driver->setRenderTarget(shadowMapTargetTexture, reset_sm_texture, true,
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
void removeNodeFromShadowList(scene::ISceneNode *node);
|
void removeNodeFromShadowList(scene::ISceneNode *node);
|
||||||
|
|
||||||
void update(video::ITexture *outputTarget = nullptr);
|
void update(video::ITexture *outputTarget = nullptr);
|
||||||
|
/// Force shadow map to be re-drawn in one go next frame
|
||||||
void setForceUpdateShadowMap() { m_force_update_shadow_map = true; }
|
void setForceUpdateShadowMap() { m_force_update_shadow_map = true; }
|
||||||
void drawDebug();
|
void drawDebug();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue