r.ReflectionEnvironmentLightmapMixBasedOnRoughness
r.ReflectionEnvironmentLightmapMixBasedOnRoughness
#Overview
name: r.ReflectionEnvironmentLightmapMixBasedOnRoughness
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to reduce lightmap mixing with reflection captures for very smooth surfaces. This is useful to make sure reflection captures match SSR / planar reflections in brightness.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ReflectionEnvironmentLightmapMixBasedOnRoughness is to control the mixing of lightmaps with reflection captures for smooth surfaces in the rendering system. It is specifically designed to ensure that reflection captures match the brightness of Screen Space Reflections (SSR) and planar reflections.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the reflection environment subsystem. It’s referenced in the ReflectionEnvironment.cpp file, which handles various aspects of environmental reflections.
The value of this variable is set through the console variable system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime using the console command “r.ReflectionEnvironmentLightmapMixBasedOnRoughness”.
This variable interacts closely with another variable named GReflectionEnvironmentBeginMixingRoughness, which defines the roughness threshold at which the mixing begins.
Developers should be aware that this variable affects the visual quality and performance of reflections in the scene. When enabled, it reduces the mixing of lightmaps with reflection captures for very smooth surfaces, which can lead to more accurate reflections but potentially at the cost of some performance.
Best practices when using this variable include:
- Testing the visual impact with it enabled and disabled to determine the best setting for your specific scene.
- Considering the performance implications, especially in scenes with many smooth, reflective surfaces.
- Using it in conjunction with other reflection-related settings to achieve the desired visual quality.
Regarding the associated variable GReflectionEnvironmentLightmapMixBasedOnRoughness:
The purpose of GReflectionEnvironmentLightmapMixBasedOnRoughness is to serve as the internal representation of the r.ReflectionEnvironmentLightmapMixBasedOnRoughness console variable. It’s used directly in the C++ code to control the behavior of the reflection environment system.
This variable is used in the GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight function to determine whether to apply the roughness-based mixing. If it’s set to 0, the function returns a default vector without considering the roughness mixing.
The value of this variable is set by the console variable system when r.ReflectionEnvironmentLightmapMixBasedOnRoughness is changed.
Developers should be aware that modifying this variable directly in C++ code is not recommended. Instead, they should use the console variable r.ReflectionEnvironmentLightmapMixBasedOnRoughness to control this behavior.
Best practices for this variable include:
- Treating it as read-only in C++ code.
- Using the console variable system to modify its value when needed.
- Considering its impact on the reflection calculation pipeline when optimizing rendering performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:56
Scope: file
Source code excerpt:
int32 GReflectionEnvironmentLightmapMixBasedOnRoughness = 1;
FAutoConsoleVariableRef CVarReflectionEnvironmentLightmapMixBasedOnRoughness(
TEXT("r.ReflectionEnvironmentLightmapMixBasedOnRoughness"),
GReflectionEnvironmentLightmapMixBasedOnRoughness,
TEXT("Whether to reduce lightmap mixing with reflection captures for very smooth surfaces. This is useful to make sure reflection captures match SSR / planar reflections in brightness."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GReflectionEnvironmentBeginMixingRoughness = .1f;
#Associated Variable and Callsites
This variable is associated with another variable named GReflectionEnvironmentLightmapMixBasedOnRoughness
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:54
Scope: file
Source code excerpt:
);
int32 GReflectionEnvironmentLightmapMixBasedOnRoughness = 1;
FAutoConsoleVariableRef CVarReflectionEnvironmentLightmapMixBasedOnRoughness(
TEXT("r.ReflectionEnvironmentLightmapMixBasedOnRoughness"),
GReflectionEnvironmentLightmapMixBasedOnRoughness,
TEXT("Whether to reduce lightmap mixing with reflection captures for very smooth surfaces. This is useful to make sure reflection captures match SSR / planar reflections in brightness."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GReflectionEnvironmentBeginMixingRoughness = .1f;
FAutoConsoleVariableRef CVarReflectionEnvironmentBeginMixingRoughness(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironment.cpp:126
Scope (from outer to inner):
file
function FVector GetReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight
Source code excerpt:
}
if (!GReflectionEnvironmentLightmapMixBasedOnRoughness)
{
return FVector(0, 1, GReflectionEnvironmentLightmapMixLargestWeight);
}
return FVector(RoughnessMixingRange, -GReflectionEnvironmentBeginMixingRoughness * RoughnessMixingRange, GReflectionEnvironmentLightmapMixLargestWeight);
}