diff options
author | x2048 <codeforsmile@gmail.com> | 2021-07-25 12:36:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 12:36:23 +0200 |
commit | bf3acbf388406f736286d990adb5f35a9023c390 (patch) | |
tree | 9fdff755e37253580c222ff768802a6b0170be10 /src/client/shadows/dynamicshadowsrender.h | |
parent | ff2d2a6e93d75d24b3f69f2b3690bcac6440961e (diff) | |
download | minetest-bf3acbf388406f736286d990adb5f35a9023c390.tar.xz |
Distribute shadow map update over multiple frames to reduce stutter (#11422)
Reduces stutter and freezes when playing.
* Maintains double SM and SM Color textures
* Light frustum update triggers incremental generation of shadow map into secondary 'future' textures.
* Every incremental update renders a portion of the shadow draw list (split equally).
* After defined number of frames (currently, 4), 'future' and 'current' textures are swapped, and DirectionalLight 'commits' the new frustum to use when rendering shadows on screen.
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src/client/shadows/dynamicshadowsrender.h')
-rw-r--r-- | src/client/shadows/dynamicshadowsrender.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/client/shadows/dynamicshadowsrender.h b/src/client/shadows/dynamicshadowsrender.h index e633bd4f7..52b24a18f 100644 --- a/src/client/shadows/dynamicshadowsrender.h +++ b/src/client/shadows/dynamicshadowsrender.h @@ -64,7 +64,6 @@ public: size_t getDirectionalLightCount() const; f32 getMaxShadowFar() const; - float getUpdateDelta() const; /// Adds a shadow to the scene node. /// The shadow mode can be ESM_BOTH, or ESM_RECEIVE. /// ESM_BOTH casts and receives shadows @@ -101,6 +100,7 @@ private: scene::ESNRP_SOLID); void renderShadowObjects(video::ITexture *target, DirectionalLight &light); void mixShadowsQuad(); + void updateSMTextures(); // a bunch of variables IrrlichtDevice *m_device{nullptr}; @@ -108,6 +108,7 @@ private: video::IVideoDriver *m_driver{nullptr}; Client *m_client{nullptr}; video::ITexture *shadowMapClientMap{nullptr}; + video::ITexture *shadowMapClientMapFuture{nullptr}; video::ITexture *shadowMapTextureFinal{nullptr}; video::ITexture *shadowMapTextureDynamicObjects{nullptr}; video::ITexture *shadowMapTextureColors{nullptr}; @@ -120,11 +121,12 @@ private: float m_shadow_map_max_distance; float m_shadow_map_texture_size; float m_time_day{0.0f}; - float m_update_delta; int m_shadow_samples; bool m_shadow_map_texture_32bit; bool m_shadows_enabled; bool m_shadow_map_colored; + u8 m_map_shadow_update_frames; /* Use this number of frames to update map shaodw */ + u8 m_current_frame{0}; /* Current frame */ video::ECOLOR_FORMAT m_texture_format{video::ECOLOR_FORMAT::ECF_R16F}; video::ECOLOR_FORMAT m_texture_format_color{video::ECOLOR_FORMAT::ECF_R16G16}; @@ -135,6 +137,7 @@ private: std::string readShaderFile(const std::string &path); s32 depth_shader{-1}; + s32 depth_shader_entities{-1}; s32 depth_shader_trans{-1}; s32 mixcsm_shader{-1}; |