diff options
author | x2048 <codeforsmile@gmail.com> | 2021-07-11 19:57:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 10:57:29 -0700 |
commit | effb5356caee01c8bfa63e98974347aab01f96ef (patch) | |
tree | 461f885d09b6658814130688a66053c0b6628151 /src/client/game.cpp | |
parent | f5706d444b02ccc1fcd854968087172d50cfcca2 (diff) | |
download | minetest-effb5356caee01c8bfa63e98974347aab01f96ef.tar.gz minetest-effb5356caee01c8bfa63e98974347aab01f96ef.tar.bz2 minetest-effb5356caee01c8bfa63e98974347aab01f96ef.zip |
Avoid draw list and shadow map update in the same frame to reduce dtime jitter (#11393)
* Separate draw list and shadows update to reduce jitter
* Avoid draw list update and shadow update in the same frame
* Force-update shadows when camera offset changes
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r-- | src/client/game.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp index 9f643e611..134c74d5d 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -609,6 +609,7 @@ struct GameRunData { float jump_timer; float damage_flash; float update_draw_list_timer; + float update_shadows_timer; f32 fog_range; @@ -3874,10 +3875,10 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, changed much */ runData.update_draw_list_timer += dtime; + runData.update_shadows_timer += dtime; float update_draw_list_delta = 0.2f; - if (ShadowRenderer *shadow = RenderingEngine::get_shadow_renderer()) - update_draw_list_delta = shadow->getUpdateDelta(); + bool draw_list_updated = false; v3f camera_direction = camera->getDirection(); if (runData.update_draw_list_timer >= update_draw_list_delta @@ -3887,8 +3888,18 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, runData.update_draw_list_timer = 0; client->getEnv().getClientMap().updateDrawList(); runData.update_draw_list_last_cam_dir = camera_direction; + draw_list_updated = true; + } - updateShadows(); + if (ShadowRenderer *shadow = RenderingEngine::get_shadow_renderer()) { + update_draw_list_delta = shadow->getUpdateDelta(); + + if (m_camera_offset_changed || + (runData.update_shadows_timer > update_draw_list_delta && + (!draw_list_updated || shadow->getDirectionalLightCount() == 0))) { + runData.update_shadows_timer = 0; + updateShadows(); + } } m_game_ui->update(*stats, client, draw_control, cam, runData.pointed_old, gui_chat_console, dtime); |