r.Mobile.Forward.EnableClusteredReflections

r.Mobile.Forward.EnableClusteredReflections

#Overview

name: r.Mobile.Forward.EnableClusteredReflections

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Mobile.Forward.EnableClusteredReflections is to enable or disable clustered reflections in mobile forward rendering. This setting variable is specifically designed for the mobile rendering system in Unreal Engine 5.

This setting variable is primarily used by the rendering subsystem, particularly for mobile platforms. It is referenced in several modules including AndroidTargetPlatformSettings, IOSTargetPlatform, and RenderCore.

The value of this variable is set in multiple places:

  1. It’s initialized as a console variable in ConsoleManager.cpp.
  2. It’s read from the engine configuration file (GEngineIni) in both AndroidTargetPlatformSettings and IOSTargetPlatform.
  3. It can be potentially modified at runtime through the console system.

This variable interacts with other rendering-related variables, such as r.Mobile.ShadingPath and r.Mobile.VirtualTextures. It’s part of a broader set of mobile rendering configuration options.

Developers should be aware of the following when using this variable:

  1. It’s specific to mobile forward rendering. It doesn’t affect mobile deferred rendering or non-mobile platforms.
  2. Changing this setting can have performance implications, as clustered reflections can be computationally expensive.
  3. It’s marked as read-only and render thread safe, indicating that it shouldn’t be changed frequently during runtime.

Best practices for using this variable include:

  1. Consider the performance impact on target mobile devices before enabling.
  2. Test thoroughly on a variety of mobile devices to ensure consistent performance and visual quality.
  3. Use in conjunction with other mobile rendering settings for optimal results.
  4. Be cautious about changing this value at runtime, as it’s marked as read-only.
  5. When building shaders, be aware that this setting affects the shader compilation process and can result in different shader permutations.

#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:3581

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMobileForwardEnableClusteredReflections(
	TEXT("r.Mobile.Forward.EnableClusteredReflections"),
	0,
	TEXT("Whether to enable clustered reflections on mobile forward, it's always supported on mobile deferred."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarMobileSupportGPUScene(
	TEXT("r.Mobile.SupportGPUScene"),

#Loc: <Workspace>/Engine/Source/Developer/Android/AndroidTargetPlatformSettings/Private/AndroidTargetPlatformSettings.cpp:19

Scope (from outer to inner):

file
function     FAndroidTargetPlatformSettings::FAndroidTargetPlatformSettings

Source code excerpt:

	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:142

Scope (from outer to inner):

file
function     class ANDROIDTARGETPLATFORMSETTINGS_API FAndroidTargetPlatformSettings : public TTargetPlatformSettingsBase<FAndroidPlatformProperties> { public: FAndroidTargetPlatformSettings

Source code excerpt:

	bool bDistanceField;

	// r.Mobile.Forward.EnableClusteredReflections value
	bool bMobileForwardEnableClusteredReflections;

	// r.Mobile.VirtualTextures value
	bool bMobileVirtualTextures;
#if WITH_ENGINE
	// Holds a cache of the target LOD settings.

#Loc: <Workspace>/Engine/Source/Developer/IOS/IOSTargetPlatform/Private/IOSTargetPlatform.cpp:43

Scope (from outer to inner):

file
function     FIOSTargetPlatform::FIOSTargetPlatform

Source code excerpt:

	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);
	DeviceHelper.OnDeviceDisconnected().AddRaw(this, &FIOSTargetPlatform::HandleDeviceDisconnected);

#Loc: <Workspace>/Engine/Source/Developer/IOS/IOSTargetPlatform/Private/IOSTargetPlatform.h:139

Scope (from outer to inner):

file
class        class FIOSTargetPlatform : public TNonDesktopTargetPlatformBase<FIOSPlatformProperties>

Source code excerpt:

	bool bDistanceField;

	// r.Mobile.Forward.EnableClusteredReflections value
	bool bMobileForwardEnableClusteredReflections;

	// r.Mobile.VirtualTextures value
	bool bMobileVirtualTextures;

#if WITH_ENGINE

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:570

Scope (from outer to inner):

file
function     bool MobileForwardEnableClusteredReflections

Source code excerpt:

RENDERCORE_API bool MobileForwardEnableClusteredReflections(const FStaticShaderPlatform Platform)
{
	static FShaderPlatformCachedIniValue<bool> MobileForwardEnableClusteredReflectionsIniValue(TEXT("r.Mobile.Forward.EnableClusteredReflections"));
	return MobileForwardEnableClusteredReflectionsIniValue.Get(Platform);
}

RENDERCORE_API bool MobileUsesShadowMaskTexture(const FStaticShaderPlatform Platform)
{
	// Only distance field shadow needs to render shadow mask texture on mobile deferred, normal shadows need to be rendered separately because of handling lighting channels.

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1725

Scope (from outer to inner):

file
function     void ShaderMapAppendKeyString

Source code excerpt:

			else
			{
				static IConsoleVariable* MobileForwardEnableClusteredReflectionsCVAR = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.Forward.EnableClusteredReflections"));
				if (MobileForwardEnableClusteredReflectionsCVAR && MobileForwardEnableClusteredReflectionsCVAR->GetInt() != 0)
				{
					KeyString += TEXT("_MobFCR");
				}
			}
		}