r.Mobile.AllowMovableDirectionalLights
r.Mobile.AllowMovableDirectionalLights
#Overview
name: r.Mobile.AllowMovableDirectionalLights
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Do not generate shader permutations to render movable directional lights.\n1: Generate shader permutations to render movable directional lights. (default)
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Mobile.AllowMovableDirectionalLights is to control the generation of shader permutations for rendering movable directional lights in mobile platforms.
This setting variable is primarily used in the rendering system, specifically for mobile platforms. It affects the following Unreal Engine subsystems and modules:
- Renderer module
- RenderCore module
The value of this variable is set in the ConsoleManager.cpp file, with a default value of 1 (enabled). It is defined as a console variable, which means it can be changed at runtime through console commands.
The associated variable CVarMobileAllowMovableDirectionalLights interacts directly with r.Mobile.AllowMovableDirectionalLights. They share the same value and are used interchangeably in the code.
Developers should be aware of the following when using this variable:
- It affects shader compilation and permutations, which can impact performance and memory usage on mobile devices.
- Changing this variable may require recompilation of shaders.
- It is marked as ECVF_RenderThreadSafe and ECVF_ReadOnly, meaning it’s safe to read from the render thread but should not be modified during runtime.
Best practices when using this variable include:
- Consider the performance implications of enabling movable directional lights on mobile platforms.
- Use this setting in conjunction with other mobile-specific rendering settings for optimal performance.
- Test thoroughly on target mobile devices when changing this setting.
Regarding the associated variable CVarMobileAllowMovableDirectionalLights:
This is the C++ representation of the console variable. It is used throughout the code to access the value of r.Mobile.AllowMovableDirectionalLights. The purpose and usage are the same as the console variable it represents. Developers should use this variable when they need to check the status of movable directional lights in C++ code, particularly in the rendering pipeline.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3522
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMobileAllowMovableDirectionalLights(
TEXT("r.Mobile.AllowMovableDirectionalLights"),
1,
TEXT("0: Do not generate shader permutations to render movable directional lights.\n"
"1: Generate shader permutations to render movable directional lights. (default)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarMobileSkyLightPermutation(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:71
Scope (from outer to inner):
file
function void FReadOnlyCVARCache::Initialize
Source code excerpt:
const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const auto CVarMobileEnableStaticAndCSMShadowReceivers = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableStaticAndCSMShadowReceivers"));
const auto CVarMobileEnableMovableLightCSMShaderCulling = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableMovableLightCSMShaderCulling"));
const auto CVarMobileAllowDistanceFieldShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowDistanceFieldShadows"));
const auto CVarMobileSkyLightPermutation = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.SkyLightPermutation"));
const auto CVarMobileEnableNoPrecomputedLightingCSMShader = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableNoPrecomputedLightingCSMShader"));
const auto CVarMobileSupportGPUScene = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.SupportGPUScene"));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.cpp:253
Scope (from outer to inner):
file
function bool FMobileMovableDirectionalLightWithLightmapPolicy::ShouldCompilePermutation
Source code excerpt:
bool FMobileMovableDirectionalLightWithLightmapPolicy::ShouldCompilePermutation(const FMeshMaterialShaderPermutationParameters& Parameters)
{
static auto* CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const bool bMobileAllowMovableDirectionalLights = CVarMobileAllowMovableDirectionalLights->GetValueOnAnyThread() != 0;
return bMobileAllowMovableDirectionalLights && Super::ShouldCompilePermutation(Parameters);
}
void FMobileMovableDirectionalLightWithLightmapPolicy::ModifyCompilationEnvironment(const FMaterialShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
#Associated Variable and Callsites
This variable is associated with another variable named CVarMobileAllowMovableDirectionalLights
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3521
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarMobileAllowMovableDirectionalLights(
TEXT("r.Mobile.AllowMovableDirectionalLights"),
1,
TEXT("0: Do not generate shader permutations to render movable directional lights.\n"
"1: Generate shader permutations to render movable directional lights. (default)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:71
Scope (from outer to inner):
file
function void FReadOnlyCVARCache::Initialize
Source code excerpt:
const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const auto CVarMobileEnableStaticAndCSMShadowReceivers = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableStaticAndCSMShadowReceivers"));
const auto CVarMobileEnableMovableLightCSMShaderCulling = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableMovableLightCSMShaderCulling"));
const auto CVarMobileAllowDistanceFieldShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowDistanceFieldShadows"));
const auto CVarMobileSkyLightPermutation = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.SkyLightPermutation"));
const auto CVarMobileEnableNoPrecomputedLightingCSMShader = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableNoPrecomputedLightingCSMShader"));
const auto CVarMobileSupportGPUScene = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.SupportGPUScene"));
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:89
Scope (from outer to inner):
file
function void FReadOnlyCVARCache::Initialize
Source code excerpt:
// mobile
bMobileHDR = CVarMobileHDR->GetValueOnAnyThread() == 1;
bMobileAllowMovableDirectionalLights = CVarMobileAllowMovableDirectionalLights->GetValueOnAnyThread() != 0;
bMobileAllowDistanceFieldShadows = CVarMobileAllowDistanceFieldShadows->GetValueOnAnyThread() != 0;
bMobileEnableStaticAndCSMShadowReceivers = CVarMobileEnableStaticAndCSMShadowReceivers->GetValueOnAnyThread() != 0;
bMobileEnableMovableLightCSMShaderCulling = CVarMobileEnableMovableLightCSMShaderCulling->GetValueOnAnyThread() != 0;
MobileSkyLightPermutationValue = CVarMobileSkyLightPermutation->GetValueOnAnyThread();
bMobileEnableNoPrecomputedLightingCSMShader = CVarMobileEnableNoPrecomputedLightingCSMShader->GetValueOnAnyThread() != 0;
MobileEarlyZPassValue = MobileEarlyZPassIniValue(GMaxRHIShaderPlatform);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.cpp:253
Scope (from outer to inner):
file
function bool FMobileMovableDirectionalLightWithLightmapPolicy::ShouldCompilePermutation
Source code excerpt:
bool FMobileMovableDirectionalLightWithLightmapPolicy::ShouldCompilePermutation(const FMeshMaterialShaderPermutationParameters& Parameters)
{
static auto* CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const bool bMobileAllowMovableDirectionalLights = CVarMobileAllowMovableDirectionalLights->GetValueOnAnyThread() != 0;
return bMobileAllowMovableDirectionalLights && Super::ShouldCompilePermutation(Parameters);
}
void FMobileMovableDirectionalLightWithLightmapPolicy::ModifyCompilationEnvironment(const FMaterialShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
{