Fix shadow atlas resizing bug
This commit is contained in:
@@ -341,10 +341,8 @@ public:
|
|||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
Lights.Clear();
|
Lights.Clear();
|
||||||
StaticAtlasPixelsUsed = 0;
|
|
||||||
StaticAtlas.Clear();
|
|
||||||
ClearDynamic();
|
ClearDynamic();
|
||||||
ViewOrigin = Vector3::Zero;
|
ClearStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitStaticAtlas()
|
void InitStaticAtlas()
|
||||||
@@ -1102,6 +1100,8 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch&
|
|||||||
if (shadows.Resolution != atlasResolution)
|
if (shadows.Resolution != atlasResolution)
|
||||||
{
|
{
|
||||||
shadows.Reset();
|
shadows.Reset();
|
||||||
|
shadows.Atlas.Reset();
|
||||||
|
shadows.StaticAtlas.Reset();
|
||||||
auto desc = GPUTextureDescription::New2D(atlasResolution, atlasResolution, _shadowMapFormat, GPUTextureFlags::ShaderResource | GPUTextureFlags::DepthStencil);
|
auto desc = GPUTextureDescription::New2D(atlasResolution, atlasResolution, _shadowMapFormat, GPUTextureFlags::ShaderResource | GPUTextureFlags::DepthStencil);
|
||||||
if (shadows.ShadowMapAtlas->Init(desc))
|
if (shadows.ShadowMapAtlas->Init(desc))
|
||||||
{
|
{
|
||||||
@@ -1110,6 +1110,7 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch&
|
|||||||
}
|
}
|
||||||
shadows.ClearShadowMapAtlas = true;
|
shadows.ClearShadowMapAtlas = true;
|
||||||
shadows.Resolution = atlasResolution;
|
shadows.Resolution = atlasResolution;
|
||||||
|
shadows.ViewOrigin = renderContext.View.Origin;
|
||||||
}
|
}
|
||||||
if (renderContext.View.Origin != shadows.ViewOrigin)
|
if (renderContext.View.Origin != shadows.ViewOrigin)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,6 +134,18 @@ public:
|
|||||||
Init(Width, Height, BordersPadding);
|
Init(Width, Height, BordersPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears and resets atlas back to the initial state.
|
||||||
|
/// </summary>
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
Width = 0;
|
||||||
|
Height = 0;
|
||||||
|
BordersPadding = 0;
|
||||||
|
Nodes.Clear();
|
||||||
|
FreeNodes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to insert a node into the atlas using rectangle pack algorithm.
|
/// Tries to insert a node into the atlas using rectangle pack algorithm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user