r.Shadow.CachedShadowsCastFromMovablePrimitives
r.Shadow.CachedShadowsCastFromMovablePrimitives
#Overview
name: r.Shadow.CachedShadowsCastFromMovablePrimitives
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether movable primitives should cast a shadow from cached whole scene shadows (movable point and spot lights).\nDisabling this can be used to remove the copy of the cached shadowmap.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.CachedShadowsCastFromMovablePrimitives is to control whether movable primitives should cast shadows from cached whole scene shadows, specifically for movable point and spot lights in the rendering system.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically in the shadow setup and rendering subsystem.
The value of this variable is set through the console variable system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime.
The associated variable GCachedShadowsCastFromMovablePrimitives directly interacts with r.Shadow.CachedShadowsCastFromMovablePrimitives. They share the same value, with GCachedShadowsCastFromMovablePrimitives being the actual variable used in the C++ code.
Developers should be aware that:
- This setting affects performance and visual quality.
- Disabling it (setting to 0) can remove the copy of the cached shadowmap, potentially improving performance at the cost of visual quality.
- It’s marked with ECVF_Scalability, indicating it’s part of the scalability settings system.
- It’s also marked as ECVF_RenderThreadSafe, meaning it can be safely changed from any thread.
Best practices when using this variable include:
- Consider the performance-quality tradeoff when adjusting this setting.
- Test thoroughly after changing the value, especially in scenes with many movable objects and dynamic lights.
- Use in conjunction with other shadow and lighting settings for optimal results.
Regarding the associated variable GCachedShadowsCastFromMovablePrimitives:
- It’s an integer variable used internally in the C++ code to represent the console variable’s value.
- It’s used in the CreateWholeSceneProjectedShadow function to determine whether to add movable primitives to the shadow’s subject primitive list.
- Developers should not modify this variable directly, but instead use the console variable r.Shadow.CachedShadowsCastFromMovablePrimitives to control its value.
- The variable is also considered alongside LightSceneInfo->Proxy->GetForceCachedShadowsForMovablePrimitives(), allowing for more granular control over shadow behavior for specific lights.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:900, section: [Android_Vulkan_SM5 DeviceProfile]
- INI Section:
Android_Vulkan_SM5 DeviceProfile
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:96
Scope: file
Source code excerpt:
int32 GCachedShadowsCastFromMovablePrimitives = 1;
FAutoConsoleVariableRef CVarCachedWholeSceneShadowsCastFromMovablePrimitives(
TEXT("r.Shadow.CachedShadowsCastFromMovablePrimitives"),
GCachedShadowsCastFromMovablePrimitives,
TEXT("Whether movable primitives should cast a shadow from cached whole scene shadows (movable point and spot lights).\n")
TEXT("Disabling this can be used to remove the copy of the cached shadowmap."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named GCachedShadowsCastFromMovablePrimitives
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:94
Scope: file
Source code excerpt:
);
int32 GCachedShadowsCastFromMovablePrimitives = 1;
FAutoConsoleVariableRef CVarCachedWholeSceneShadowsCastFromMovablePrimitives(
TEXT("r.Shadow.CachedShadowsCastFromMovablePrimitives"),
GCachedShadowsCastFromMovablePrimitives,
TEXT("Whether movable primitives should cast a shadow from cached whole scene shadows (movable point and spot lights).\n")
TEXT("Disabling this can be used to remove the copy of the cached shadowmap."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
// Temporary chicken bit to back out optimization if there are any issues
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:4320
Scope (from outer to inner):
file
function void FSceneRenderer::CreateWholeSceneProjectedShadow
Source code excerpt:
}
bool bCastCachedShadowFromMovablePrimitives = GCachedShadowsCastFromMovablePrimitives || LightSceneInfo->Proxy->GetForceCachedShadowsForMovablePrimitives();
if (CacheMode[CacheModeIndex] != SDCM_StaticPrimitivesOnly
&& (CacheMode[CacheModeIndex] != SDCM_MovablePrimitivesOnly || bCastCachedShadowFromMovablePrimitives))
{
// Add all the shadow casting primitives affected by the light to the shadow's subject primitive list.
AddInteractingPrimitives(LightSceneInfo->GetDynamicInteractionOftenMovingPrimitiveList(), ProjectedShadowInfo, bContainsNaniteSubjects, LightViewFrustumConvexHulls, nullptr);
}