r.Mobile.ShadingPath
r.Mobile.ShadingPath
#Overview
name: r.Mobile.ShadingPath
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Forward shading (default)\n1: Deferred shading (Mobile HDR is required for Deferred)
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Mobile.ShadingPath is to control the shading path used for mobile rendering in Unreal Engine 5. It determines whether forward shading or deferred shading is employed on mobile platforms.
This setting variable is primarily used by the rendering system, specifically for mobile rendering. It’s referenced in various modules related to mobile platform support, including Android and iOS target platform settings, as well as in the core rendering code.
The value of this variable is set in the engine configuration file (GEngineIni) under the “/Script/Engine.RendererSettings” section. It can be accessed and modified through the console variable system.
The r.Mobile.ShadingPath interacts with other rendering-related variables, such as:
- r.DistanceFields
- r.Mobile.Forward.EnableClusteredReflections
- r.Mobile.VirtualTextures
- r.Mobile.AllowDeferredShadingOpenGL
Developers should be aware that:
- The default value is 0, which corresponds to forward shading.
- A value of 1 enables deferred shading, which requires Mobile HDR to be enabled.
- Deferred shading might not be supported on all mobile platforms, particularly OpenGL-based ones.
Best practices when using this variable include:
- Consider the performance implications of switching between forward and deferred shading on mobile devices.
- Ensure that Mobile HDR is enabled when using deferred shading.
- Test thoroughly on target mobile devices to ensure compatibility and performance.
- Be aware of platform-specific limitations, especially for OpenGL-based platforms.
- Consider the interaction with other mobile rendering settings to achieve the desired visual quality and performance balance.
#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:3473
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMobileShadingPath(
TEXT("r.Mobile.ShadingPath"),
0,
TEXT("0: Forward shading (default)\n"
"1: Deferred shading (Mobile HDR is required for Deferred)"),
ECVF_RenderThreadSafe | ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarMobileAllowDeferredShadingOpenGL(
#Loc: <Workspace>/Engine/Source/Developer/Android/AndroidTargetPlatformSettings/Private/AndroidTargetPlatformSettings.cpp:18
Scope (from outer to inner):
file
function FAndroidTargetPlatformSettings::FAndroidTargetPlatformSettings
Source code excerpt:
StaticMeshLODSettings.Initialize(this);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.DistanceFields"), bDistanceField, GEngineIni);
GetConfigSystem()->GetInt(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.ShadingPath"), MobileShadingPath, GEngineIni);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.Forward.EnableClusteredReflections"), bMobileForwardEnableClusteredReflections, GEngineIni);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.VirtualTextures"), bMobileVirtualTextures, GEngineIni);
#endif
}
bool FAndroidTargetPlatformSettings::SupportsES31() const
#Loc: <Workspace>/Engine/Source/Developer/Android/AndroidTargetPlatformSettings/Public/AndroidTargetPlatformSettings.h:136
Scope (from outer to inner):
file
function class ANDROIDTARGETPLATFORMSETTINGS_API FAndroidTargetPlatformSettings : public TTargetPlatformSettingsBase<FAndroidPlatformProperties> { public: FAndroidTargetPlatformSettings
Source code excerpt:
// r.Mobile.ShadingPath value
int32 MobileShadingPath;
// true if DistanceField is enabled
bool bDistanceField;
// r.Mobile.Forward.EnableClusteredReflections value
#Loc: <Workspace>/Engine/Source/Developer/IOS/IOSTargetPlatform/Private/IOSTargetPlatform.cpp:42
Scope (from outer to inner):
file
function FIOSTargetPlatform::FIOSTargetPlatform
Source code excerpt:
StaticMeshLODSettings.Initialize(this);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.DistanceFields"), bDistanceField, GEngineIni);
GetConfigSystem()->GetInt(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.ShadingPath"), MobileShadingPath, GEngineIni);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.Forward.EnableClusteredReflections"), bMobileForwardEnableClusteredReflections, GEngineIni);
GetConfigSystem()->GetBool(TEXT("/Script/Engine.RendererSettings"), TEXT("r.Mobile.VirtualTextures"), bMobileVirtualTextures, GEngineIni);
#endif // #if WITH_ENGINE
// initialize the connected device detector
DeviceHelper.OnDeviceConnected().AddRaw(this, &FIOSTargetPlatform::HandleDeviceConnected);
#Loc: <Workspace>/Engine/Source/Developer/IOS/IOSTargetPlatform/Private/IOSTargetPlatform.h:133
Scope (from outer to inner):
file
class class FIOSTargetPlatform : public TNonDesktopTargetPlatformBase<FIOSPlatformProperties>
Source code excerpt:
TSharedPtr<FMessageEndpoint, ESPMode::ThreadSafe> MessageEndpoint;
// r.Mobile.ShadingPath value
int32 MobileShadingPath;
// true if DistanceField is enabled
bool bDistanceField;
// r.Mobile.Forward.EnableClusteredReflections value
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:45
Scope (from outer to inner):
file
function bool FReadOnlyCVARCache::MobileDeferredShadingIniValue
Source code excerpt:
bool FReadOnlyCVARCache::MobileDeferredShadingIniValue(EShaderPlatform Platform)
{
static FShaderPlatformCachedIniValue<bool> MobileShadingPathIniValue(TEXT("r.Mobile.ShadingPath"));
static TConsoleVariableData<int32>* MobileAllowDeferredShadingOpenGL = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowDeferredShadingOpenGL"));
// a separate cvar so we can exclude deferred from OpenGL specificaly
const bool bSupportedPlatform = !IsOpenGLPlatform(Platform) || (MobileAllowDeferredShadingOpenGL && MobileAllowDeferredShadingOpenGL->GetValueOnAnyThread() != 0);
return MobileShadingPathIniValue.Get(Platform) && bSupportedPlatform;
}