diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp
index 68f26d05e..55293a1df 100644
--- a/Source/Engine/Renderer/ShadowsPass.cpp
+++ b/Source/Engine/Renderer/ShadowsPass.cpp
@@ -341,10 +341,8 @@ public:
void Reset()
{
Lights.Clear();
- StaticAtlasPixelsUsed = 0;
- StaticAtlas.Clear();
ClearDynamic();
- ViewOrigin = Vector3::Zero;
+ ClearStatic();
}
void InitStaticAtlas()
@@ -1102,6 +1100,8 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch&
if (shadows.Resolution != atlasResolution)
{
shadows.Reset();
+ shadows.Atlas.Reset();
+ shadows.StaticAtlas.Reset();
auto desc = GPUTextureDescription::New2D(atlasResolution, atlasResolution, _shadowMapFormat, GPUTextureFlags::ShaderResource | GPUTextureFlags::DepthStencil);
if (shadows.ShadowMapAtlas->Init(desc))
{
@@ -1110,6 +1110,7 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch&
}
shadows.ClearShadowMapAtlas = true;
shadows.Resolution = atlasResolution;
+ shadows.ViewOrigin = renderContext.View.Origin;
}
if (renderContext.View.Origin != shadows.ViewOrigin)
{
diff --git a/Source/Engine/Utilities/RectPack.h b/Source/Engine/Utilities/RectPack.h
index 8217effe4..38a163a3d 100644
--- a/Source/Engine/Utilities/RectPack.h
+++ b/Source/Engine/Utilities/RectPack.h
@@ -134,6 +134,18 @@ public:
Init(Width, Height, BordersPadding);
}
+ ///
+ /// Clears and resets atlas back to the initial state.
+ ///
+ void Reset()
+ {
+ Width = 0;
+ Height = 0;
+ BordersPadding = 0;
+ Nodes.Clear();
+ FreeNodes.Clear();
+ }
+
///
/// Tries to insert a node into the atlas using rectangle pack algorithm.
///