r.Shadow.Virtual.Cache.DeformableMeshesInvalidate
r.Shadow.Virtual.Cache.DeformableMeshesInvalidate
#Overview
name: r.Shadow.Virtual.Cache.DeformableMeshesInvalidate
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If enabled, Primitive Proxies that are marked as having deformable meshes (HasDeformableMesh() == true) cause invalidations regardless of whether their transforms are updated.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.Virtual.Cache.DeformableMeshesInvalidate is to control the invalidation behavior of the Virtual Shadow Map (VSM) cache for deformable meshes in Unreal Engine 5’s rendering system.
This setting variable is primarily used by the Virtual Shadow Map system, which is part of Unreal Engine’s rendering module. It specifically affects the caching mechanism for shadow maps of deformable meshes.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 1 (enabled) in the C++ code.
The associated variable GVSMCacheDeformableMeshesInvalidate directly interacts with r.Shadow.Virtual.Cache.DeformableMeshesInvalidate. They share the same value and purpose.
Developers must be aware that when this variable is enabled (set to non-zero), it causes the Virtual Shadow Map cache to invalidate for Primitive Proxies that are marked as having deformable meshes (HasDeformableMesh() == true), regardless of whether their transforms are updated. This is particularly important for objects like skinned meshes that may be animating but not moving in world space.
Best practices when using this variable include:
- Keep it enabled (default value of 1) for most scenarios to ensure accurate shadows for deformable meshes.
- If you’re experiencing performance issues related to frequent shadow map invalidations, and you’re certain that your deformable meshes don’t require constant shadow updates, you might consider disabling it. However, this should be done cautiously and with thorough testing.
- Use in conjunction with other shadow-related settings for optimal performance and visual quality.
Regarding the associated variable GVSMCacheDeformableMeshesInvalidate:
The purpose of GVSMCacheDeformableMeshesInvalidate is identical to r.Shadow.Virtual.Cache.DeformableMeshesInvalidate. It’s the internal C++ variable that directly controls the behavior described.
This variable is used within the rendering subsystem, specifically in the Virtual Shadow Map cache management code.
Its value is set by the console variable system, mirroring r.Shadow.Virtual.Cache.DeformableMeshesInvalidate.
It directly interacts with the logic that determines whether to invalidate the shadow cache for deformable meshes.
Developers should be aware that this is the actual variable used in the code logic, while r.Shadow.Virtual.Cache.DeformableMeshesInvalidate is the console-accessible name.
Best practices for GVSMCacheDeformableMeshesInvalidate are the same as for r.Shadow.Virtual.Cache.DeformableMeshesInvalidate, as they are essentially the same variable with different access methods.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapCacheManager.cpp:57
Scope: file
Source code excerpt:
static int32 GVSMCacheDeformableMeshesInvalidate = 1;
FAutoConsoleVariableRef CVarCacheInvalidateOftenMoving(
TEXT("r.Shadow.Virtual.Cache.DeformableMeshesInvalidate"),
GVSMCacheDeformableMeshesInvalidate,
TEXT("If enabled, Primitive Proxies that are marked as having deformable meshes (HasDeformableMesh() == true) cause invalidations regardless of whether their transforms are updated."),
ECVF_RenderThreadSafe);
int32 GForceInvalidateDirectionalVSM = 0;
static FAutoConsoleVariableRef CVarForceInvalidateDirectionalVSM(
#Associated Variable and Callsites
This variable is associated with another variable named GVSMCacheDeformableMeshesInvalidate
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapCacheManager.cpp:55
Scope: file
Source code excerpt:
);
static int32 GVSMCacheDeformableMeshesInvalidate = 1;
FAutoConsoleVariableRef CVarCacheInvalidateOftenMoving(
TEXT("r.Shadow.Virtual.Cache.DeformableMeshesInvalidate"),
GVSMCacheDeformableMeshesInvalidate,
TEXT("If enabled, Primitive Proxies that are marked as having deformable meshes (HasDeformableMesh() == true) cause invalidations regardless of whether their transforms are updated."),
ECVF_RenderThreadSafe);
int32 GForceInvalidateDirectionalVSM = 0;
static FAutoConsoleVariableRef CVarForceInvalidateDirectionalVSM(
TEXT("r.Shadow.Virtual.Cache.ForceInvalidateDirectional"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapCacheManager.cpp:845
Scope (from outer to inner):
file
function void FVirtualShadowMapPerLightCacheEntry::OnPrimitiveRendered
Source code excerpt:
CachedPrimitives[PrimitiveSceneInfo->GetPersistentIndex().Index] = true;
if (GVSMCacheDeformableMeshesInvalidate != 0)
{
// Deformable mesh primitives need to trigger invalidation (even if they did not move) or we get artifacts, for example skinned meshes that are animating but not currently moving.
// Skip if the invalidation mode is NOT auto (because Always will do it elsewhere & the others should prevent this).
if (PrimitiveSceneInfo->Proxy->HasDeformableMesh() && PrimitiveSceneInfo->Proxy->GetShadowCacheInvalidationBehavior() == EShadowCacheInvalidationBehavior::Auto)
{
PrimitiveInstancesToInvalidate.Add(FVirtualShadowMapInstanceRange{