From 2b9c0509110e9fb7faea136a9483461281aba4a3 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 7 Aug 2024 23:46:18 +0200 Subject: [PATCH] Add `Graphics.ShadowUpdateRate` to control global shadows atlas update rate --- Source/Engine/Graphics/Graphics.cpp | 1 + Source/Engine/Graphics/Graphics.h | 5 +++++ Source/Engine/Renderer/ShadowsPass.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp index 489299714..a1640c0b4 100644 --- a/Source/Engine/Graphics/Graphics.cpp +++ b/Source/Engine/Graphics/Graphics.cpp @@ -18,6 +18,7 @@ Quality Graphics::SSAOQuality = Quality::Medium; Quality Graphics::VolumetricFogQuality = Quality::High; Quality Graphics::ShadowsQuality = Quality::Medium; Quality Graphics::ShadowMapsQuality = Quality::Medium; +float Graphics::ShadowUpdateRate = 1.0f; bool Graphics::AllowCSMBlending = false; Quality Graphics::GlobalSDFQuality = Quality::High; Quality Graphics::GIQuality = Quality::High; diff --git a/Source/Engine/Graphics/Graphics.h b/Source/Engine/Graphics/Graphics.h index 59c5bfd1c..4c5e0ad26 100644 --- a/Source/Engine/Graphics/Graphics.h +++ b/Source/Engine/Graphics/Graphics.h @@ -48,6 +48,11 @@ public: /// API_FIELD() static Quality ShadowMapsQuality; + /// + /// The global scale for all shadow maps update rate. Can be used to slow down shadows rendering frequency on lower quality settings or low-end platforms. Default 1. + /// + API_FIELD() static float ShadowUpdateRate; + /// /// Enables cascades splits blending for directional light shadows. /// [Deprecated in v1.9] diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 9b65e9c3e..b98dd9999 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -224,7 +224,7 @@ struct ShadowAtlasLight const float shadowsUpdateRate = light.ShadowsUpdateRate; const float shadowsUpdateRateAtDistance = shadowsUpdateRate * light.ShadowsUpdateRateAtDistance; float updateRate = Math::Lerp(shadowsUpdateRate, shadowsUpdateRateAtDistance, Math::Saturate(distanceFromView / Distance)); - // TODO: add global shadows update rate scale to be adjusted per-platform + updateRate *= Graphics::ShadowUpdateRate; freezeUpdate = updateRate <= ZeroTolerance; if (freezeUpdate) return 0.0f;