r.Mobile.ShadingPath

r.Mobile.ShadingPath

#Overview

name: r.Mobile.ShadingPath

This variable is created as a Console Variable (cvar).

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:

  1. r.DistanceFields
  2. r.Mobile.Forward.EnableClusteredReflections
  3. r.Mobile.VirtualTextures
  4. r.Mobile.AllowDeferredShadingOpenGL

Developers should be aware that:

  1. The default value is 0, which corresponds to forward shading.
  2. A value of 1 enables deferred shading, which requires Mobile HDR to be enabled.
  3. Deferred shading might not be supported on all mobile platforms, particularly OpenGL-based ones.

Best practices when using this variable include:

  1. Consider the performance implications of switching between forward and deferred shading on mobile devices.
  2. Ensure that Mobile HDR is enabled when using deferred shading.
  3. Test thoroughly on target mobile devices to ensure compatibility and performance.
  4. Be aware of platform-specific limitations, especially for OpenGL-based platforms.
  5. 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;
}