Add InvalidateShadow for manual shadow cache refresh

This commit is contained in:
Wojtek Figat
2024-04-11 16:34:42 +02:00
parent 803249f126
commit a532ea7b42
7 changed files with 20 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ struct RenderLightData
float ShadowsUpdateRate;
float ShadowsUpdateRateAtDistance;
uint32 ShadowFrame;
bool CanRenderShadow(const RenderView& view) const;
};

View File

@@ -121,6 +121,7 @@ struct ShadowAtlasLightCache
bool DynamicValid;
float ShadowsUpdateRate;
float ShadowsUpdateRateAtDistance;
uint32 ShadowFrame;
float OuterConeAngle;
Float3 Position;
float Radius;
@@ -136,6 +137,7 @@ struct ShadowAtlasLightCache
ShadowsUpdateRate = light.ShadowsUpdateRate;
ShadowsUpdateRateAtDistance = light.ShadowsUpdateRateAtDistance;
Direction = light.Direction;
ShadowFrame = light.ShadowFrame;
if (light.IsDirectionalLight)
{
// Sun
@@ -229,6 +231,7 @@ struct ShadowAtlasLight
if (!Math::NearEqual(Cache.Distance, light.ShadowsDistance) ||
!Math::NearEqual(Cache.ShadowsUpdateRate, light.ShadowsUpdateRate) ||
!Math::NearEqual(Cache.ShadowsUpdateRateAtDistance, light.ShadowsUpdateRateAtDistance) ||
Cache.ShadowFrame != light.ShadowFrame ||
Float3::Dot(Cache.Direction, light.Direction) < 0.999999f)
{
// Invalidate