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).

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:

  1. This setting affects performance and visual quality.
  2. Disabling it (setting to 0) can remove the copy of the cached shadowmap, potentially improving performance at the cost of visual quality.
  3. It’s marked with ECVF_Scalability, indicating it’s part of the scalability settings system.
  4. It’s also marked as ECVF_RenderThreadSafe, meaning it can be safely changed from any thread.

Best practices when using this variable include:

  1. Consider the performance-quality tradeoff when adjusting this setting.
  2. Test thoroughly after changing the value, especially in scenes with many movable objects and dynamic lights.
  3. Use in conjunction with other shadow and lighting settings for optimal results.

Regarding the associated variable GCachedShadowsCastFromMovablePrimitives:

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:900, section: [Android_Vulkan_SM5 DeviceProfile]

#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);
							}