r.ReflectionEnvironment

r.ReflectionEnvironment

#Overview

name: r.ReflectionEnvironment

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ReflectionEnvironment is to control the rendering of the reflection environment feature in Unreal Engine. This feature implements local reflections through Reflection Capture actors.

The Unreal Engine rendering system, specifically the reflection environment module, relies on this setting variable. It is primarily used in the ReflectionEnvironment.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVar) system. It can be changed at runtime using console commands or through configuration files.

The associated variable CVarReflectionEnvironment interacts directly with r.ReflectionEnvironment. They share the same value and purpose.

Developers must be aware that this variable has three possible values: 0: Turns off the reflection environment feature 1: Enables the feature and blends reflections with the scene (default) 2: Enables the feature and overwrites the scene with reflections (only available in non-shipping builds)

Best practices when using this variable include:

  1. Use the default value (1) for most scenarios, as it provides a balance between visual quality and performance.
  2. Consider turning it off (0) for performance-critical situations or on lower-end hardware.
  3. Be cautious when using value 2, as it’s intended for debugging and is not available in shipping builds.

Regarding the associated variable CVarReflectionEnvironment:

The purpose of CVarReflectionEnvironment is to provide programmatic access to the r.ReflectionEnvironment setting within the C++ code.

It is used in the Renderer module, specifically in the reflection environment rendering code.

The value of CVarReflectionEnvironment is set when the console variable r.ReflectionEnvironment is modified.

The GetReflectionEnvironmentCVar() function uses CVarReflectionEnvironment to retrieve the current value of the setting.

Developers should be aware that changes to CVarReflectionEnvironment will directly affect the behavior of the reflection environment rendering.

Best practices for using CVarReflectionEnvironment include:

  1. Use GetValueOnAnyThread() to safely retrieve the current value from any thread.
  2. Be aware of the build configuration limitations (value 2 is not available in shipping or test builds).
  3. Consider performance implications when modifying this value at runtime.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarReflectionEnvironment(
	TEXT("r.ReflectionEnvironment"),
	1,
	TEXT("Whether to render the reflection environment feature, which implements local reflections through Reflection Capture actors.\n")
	TEXT(" 0: off\n")
	TEXT(" 1: on and blend with scene (default)")
	TEXT(" 2: on and overwrite scene (only in non-shipping builds)"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

#include "HairStrands/HairStrandsRendering.h"

static TAutoConsoleVariable<int32> CVarReflectionEnvironment(
	TEXT("r.ReflectionEnvironment"),
	1,
	TEXT("Whether to render the reflection environment feature, which implements local reflections through Reflection Capture actors.\n")
	TEXT(" 0: off\n")
	TEXT(" 1: on and blend with scene (default)")
	TEXT(" 2: on and overwrite scene (only in non-shipping builds)"),

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

Scope (from outer to inner):

file
function     int GetReflectionEnvironmentCVar

Source code excerpt:

int GetReflectionEnvironmentCVar()
{
	int32 RetVal = CVarReflectionEnvironment.GetValueOnAnyThread();

#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
	// Disabling the debug part of this CVar when in shipping
	if (RetVal == 2)
	{
		RetVal = 1;