r.DoTiledReflections

r.DoTiledReflections

#Overview

name: r.DoTiledReflections

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DoTiledReflections is to control whether the Reflection Environment is computed using a tiled compute shader in Unreal Engine’s rendering system.

This setting variable is primarily used by the rendering subsystem of Unreal Engine, specifically in the Reflection Environment computation. It’s referenced in the Renderer module and the MetalRHI (Metal Rendering Hardware Interface) module.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (on) in the Renderer module, but it can be modified at runtime through console commands or programmatically.

The associated variable CVarDoTiledReflections directly interacts with r.DoTiledReflections. They essentially represent the same setting, with CVarDoTiledReflections being the actual console variable object that can be queried and modified in the code.

Developers should be aware that this setting might be automatically disabled on certain hardware configurations, particularly in the Metal rendering backend. The MetalRHI code checks for tiled reflection support and may override this setting if the hardware doesn’t support it.

Best practices when using this variable include:

  1. Be cautious when manually changing this setting, as it may impact performance and visual quality.
  2. Consider the target hardware capabilities, especially when developing for Apple platforms using Metal.
  3. Use the associated CVarDoTiledReflections when querying or modifying this setting in C++ code.

Regarding CVarDoTiledReflections: This is the actual console variable object associated with r.DoTiledReflections. It’s used to programmatically access and modify the setting. The purpose and impact are the same as r.DoTiledReflections. It’s defined in the Renderer module and accessed in the MetalRHI module to potentially disable tiled reflections based on hardware support.

Developers should use CVarDoTiledReflections when they need to query or modify the setting in C++ code. For example:

auto CVarDoTiledReflections = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DoTiledReflections"));
if (CVarDoTiledReflections)
{
    bool bTiledReflectionsEnabled = (CVarDoTiledReflections->GetInt() != 0);
    // Use the value as needed
}

This approach ensures that the code interacts with the setting in a way that’s consistent with the engine’s console variable system.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:87

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDoTiledReflections(
	TEXT("r.DoTiledReflections"),
	1,
	TEXT("Compute Reflection Environment with Tiled compute shader..\n")
	TEXT(" 0: off\n")
	TEXT(" 1: on (default)"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:492

Scope: file

Source code excerpt:

	if (!bSupportsTiledReflections && !FParse::Param(FCommandLine::Get(),TEXT("metaltiledreflections")))
	{
		static auto CVarDoTiledReflections = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DoTiledReflections"));
		if(CVarDoTiledReflections && CVarDoTiledReflections->GetInt() != 0)
		{
			CVarDoTiledReflections->Set(0);
		}
	}
	

#Associated Variable and Callsites

This variable is associated with another variable named CVarDoTiledReflections. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:492

Scope: file

Source code excerpt:

	if (!bSupportsTiledReflections && !FParse::Param(FCommandLine::Get(),TEXT("metaltiledreflections")))
	{
		static auto CVarDoTiledReflections = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DoTiledReflections"));
		if(CVarDoTiledReflections && CVarDoTiledReflections->GetInt() != 0)
		{
			CVarDoTiledReflections->Set(0);
		}
	}
	
	// Disable the distance field AO & shadowing effects on GPU drivers that don't currently execute the shaders correctly.
	if ((GMaxRHIShaderPlatform == SP_METAL_SM5 || GMaxRHIShaderPlatform == SP_METAL_SM6) && !bSupportsDistanceFields && !FParse::Param(FCommandLine::Get(),TEXT("metaldistancefields")))
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:86

Scope: file

Source code excerpt:

	);

static TAutoConsoleVariable<int32> CVarDoTiledReflections(
	TEXT("r.DoTiledReflections"),
	1,
	TEXT("Compute Reflection Environment with Tiled compute shader..\n")
	TEXT(" 0: off\n")
	TEXT(" 1: on (default)"),
	ECVF_RenderThreadSafe);