From fa8f50ead13f1653c699f230c3aa935b389fa41a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 16 Dec 2024 22:52:05 +0100 Subject: [PATCH] Fix crash on incorrect light shadow state after shadowmap resizing failure #3106 --- Source/Engine/Renderer/ShadowsPass.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 0487d7ce2..f182b9848 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -623,10 +623,6 @@ void ShadowsPass::SetupRenderContext(RenderContext& renderContext, RenderContext void ShadowsPass::SetupLight(ShadowsCustomBuffer& shadows, RenderContext& renderContext, RenderContextBatch& renderContextBatch, RenderLightData& light, ShadowAtlasLight& atlasLight) { - // Initialize frame-data - atlasLight.ContextIndex = 0; - atlasLight.ContextCount = 0; - // Copy light properties atlasLight.Sharpness = light.ShadowsSharpness; atlasLight.Fade = light.ShadowsStrength; @@ -1298,6 +1294,11 @@ RETRY_ATLAS_SETUP: for (RenderLightData* light : shadowedLights) { auto& atlasLight = shadows.Lights[light->ID]; + + // Reset frame-data + atlasLight.ContextIndex = 0; + atlasLight.ContextCount = 0; + if (atlasLight.Tiles[0].RectTile && atlasLight.Tiles[0].RectTile->Width == atlasLight.Resolution) { // Invalidate cache when whole atlas will be cleared