Fix crash on incorrect light shadow state after shadowmap resizing failure

#3106
This commit is contained in:
Wojtek Figat
2024-12-16 22:52:05 +01:00
parent 4a2f4a98ec
commit fa8f50ead1

View File

@@ -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