r.Mobile.EnableMovableSpotlightsShadow

r.Mobile.EnableMovableSpotlightsShadow

#Overview

name: r.Mobile.EnableMovableSpotlightsShadow

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.Mobile.EnableMovableSpotlightsShadow is to enable or disable movable spotlight shadow support for mobile platforms in Unreal Engine 5.

This setting variable is primarily used by the Renderer subsystem, specifically for mobile rendering and shadow depth rendering. It’s referenced in the MobileBasePassRendering and ShadowDepthRendering modules.

The value of this variable is set through a console variable (CVar) defined in the engine. It can be modified via console commands or configuration files. The default value is 0, meaning movable spotlight shadows are disabled by default on mobile platforms.

This variable interacts with other mobile rendering settings, particularly those related to shadow rendering. For example, it works in conjunction with r.Mobile.MaxVisibleMovableSpotLightShadows, which controls the maximum number of visible movable spotlight shadows.

Developers must be aware that enabling this feature may have performance implications on mobile devices. It should be used judiciously, considering the target hardware capabilities and performance requirements of the game.

Best practices when using this variable include:

  1. Only enable it when necessary for the visual quality of the game on mobile platforms.
  2. Test thoroughly on various mobile devices to ensure performance is not significantly impacted.
  3. Consider using it in combination with other shadow quality settings to find the right balance between visual fidelity and performance.
  4. Be aware that changing this setting may require shader recompilation, which could impact load times or runtime performance.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.cpp:31

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMobileEnableMovableSpotLightShadows(
	TEXT("r.Mobile.EnableMovableSpotlightsShadow"),
	0,
	TEXT("If 1 then enable movable spotlight shadow support"),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarMobileMaxVisibleMovableSpotLightShadows(
	TEXT("r.Mobile.MaxVisibleMovableSpotLightShadows"),

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:54

Scope (from outer to inner):

file
function     bool FReadOnlyCVARCache::MobileEnableMovableSpotlightsShadowIniValue

Source code excerpt:

bool FReadOnlyCVARCache::MobileEnableMovableSpotlightsShadowIniValue(EShaderPlatform Platform)
{
	static FShaderPlatformCachedIniValue<bool> CVar(TEXT("r.Mobile.EnableMovableSpotlightsShadow"));
	return CVar.Get(Platform);
}

void FReadOnlyCVARCache::Initialize()
{
	UE_LOG(LogInit, Log, TEXT("Initializing FReadOnlyCVARCache"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:289

Scope (from outer to inner):

file
function     static bool MobileUsesPerspectiveCorrectShadowPermutation

Source code excerpt:

{
	// Required only for spotlight shadows on mobile
	static FShaderPlatformCachedIniValue<bool> MobileEnableMovableSpotlightShadowsIniValue(TEXT("r.Mobile.EnableMovableSpotlightsShadow"));
	const bool bMobileEnableMovableSpotlightShadows = (MobileEnableMovableSpotlightShadowsIniValue.Get(ShaderPlatform) != 0);
	return bMobileEnableMovableSpotlightShadows;
}


static TAutoConsoleVariable<int32> CVarDetectVertexShaderLayerAtRuntime(