r.ReflectionEnvironmentBeginMixingRoughness

r.ReflectionEnvironmentBeginMixingRoughness

#Overview

name: r.ReflectionEnvironmentBeginMixingRoughness

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.ReflectionEnvironmentBeginMixingRoughness is to control the minimum roughness value at which the rendering system begins mixing reflection captures with lightmap indirect diffuse in the reflection environment.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the reflection environment system. It’s part of the rendering pipeline that handles environmental reflections and lighting.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 0.1f and can be modified at runtime using console commands or through project settings.

This variable interacts closely with GReflectionEnvironmentEndMixingRoughness. Together, these two variables define a range of roughness values over which the mixing of reflection captures and lightmap indirect diffuse occurs.

Developers should be aware that this variable affects the visual quality and performance of reflections in the game. Lower values will start the mixing process at smoother surfaces, potentially increasing the overall quality of reflections but at the cost of performance.

Best practices when using this variable include:

  1. Balancing it with GReflectionEnvironmentEndMixingRoughness to create a smooth transition.
  2. Adjusting it based on the specific visual requirements of your project.
  3. Considering its impact on performance, especially on lower-end hardware.

Regarding the associated variable GReflectionEnvironmentBeginMixingRoughness:

The purpose of GReflectionEnvironmentBeginMixingRoughness is to store the actual value used by the engine for the minimum roughness at which mixing begins. It’s the C++ variable that holds the value set by the console variable r.ReflectionEnvironmentBeginMixingRoughness.

This variable is used directly in the rendering calculations, specifically in the GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight function. This function appears to calculate parameters for the shader that performs the reflection mixing.

The value of GReflectionEnvironmentBeginMixingRoughness is set by the console variable system, allowing it to be easily modified at runtime or through configuration files.

It interacts closely with GReflectionEnvironmentEndMixingRoughness and other reflection environment variables to control the overall behavior of the reflection system.

Developers should be aware that modifying this variable directly in C++ code might not be the best practice, as it could be overwritten by the console variable system. Instead, they should use the console variable r.ReflectionEnvironmentBeginMixingRoughness to ensure consistent behavior.

Best practices for this variable include:

  1. Using it in conjunction with other reflection environment variables for a cohesive reflection system.
  2. Considering its impact on both visual quality and performance when adjusting its value.
  3. Testing any changes across a range of hardware to ensure consistent results.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

float GReflectionEnvironmentBeginMixingRoughness = .1f;
FAutoConsoleVariableRef CVarReflectionEnvironmentBeginMixingRoughness(
	TEXT("r.ReflectionEnvironmentBeginMixingRoughness"),
	GReflectionEnvironmentBeginMixingRoughness,
	TEXT("Min roughness value at which to begin mixing reflection captures with lightmap indirect diffuse."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GReflectionEnvironmentEndMixingRoughness = .3f;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

float GReflectionEnvironmentBeginMixingRoughness = .1f;
FAutoConsoleVariableRef CVarReflectionEnvironmentBeginMixingRoughness(
	TEXT("r.ReflectionEnvironmentBeginMixingRoughness"),
	GReflectionEnvironmentBeginMixingRoughness,
	TEXT("Min roughness value at which to begin mixing reflection captures with lightmap indirect diffuse."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GReflectionEnvironmentEndMixingRoughness = .3f;
FAutoConsoleVariableRef CVarReflectionEnvironmentEndMixingRoughness(

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

Scope (from outer to inner):

file
function     FVector GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight

Source code excerpt:

FVector GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight()
{
	float RoughnessMixingRange = 1.0f / FMath::Max(GReflectionEnvironmentEndMixingRoughness - GReflectionEnvironmentBeginMixingRoughness, .001f);

	if (GReflectionEnvironmentLightmapMixing == 0)
	{
		return FVector(0, 0, GReflectionEnvironmentLightmapMixLargestWeight);
	}

	if (GReflectionEnvironmentEndMixingRoughness == 0.0f && GReflectionEnvironmentBeginMixingRoughness == 0.0f)
	{
		// Make sure a Roughness of 0 results in full mixing when disabling roughness-based mixing
		return FVector(0, 1, GReflectionEnvironmentLightmapMixLargestWeight);
	}

	if (!GReflectionEnvironmentLightmapMixBasedOnRoughness)

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

Scope (from outer to inner):

file
function     FVector GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight

Source code excerpt:

	}

	return FVector(RoughnessMixingRange, -GReflectionEnvironmentBeginMixingRoughness * RoughnessMixingRange, GReflectionEnvironmentLightmapMixLargestWeight);
}

bool IsReflectionEnvironmentAvailable(ERHIFeatureLevel::Type InFeatureLevel)
{
	return (SupportsTextureCubeArray(InFeatureLevel)) && (GetReflectionEnvironmentCVar() != 0);
}