r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale

r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale

#Overview

name: r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale

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.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale is to control the scaling of the normal angle threshold in the bilateral filter used for Lumen reflections. This setting variable is part of the rendering system, specifically the Lumen global illumination and reflection system in Unreal Engine 5.

The Lumen reflection system in Unreal Engine’s renderer subsystem relies on this setting variable. It is used within the LumenReflections.cpp file, which is part of the Renderer module.

The value of this variable is set through the engine’s console variable system. It is initialized with a default value of 1.0f and can be modified at runtime or through configuration files.

This variable interacts directly with GLumenReflectionBilateralFilterNormalAngleThresholdScale, which is the associated C++ variable that holds the actual value used in the rendering code.

Developers should be aware that this variable affects the quality and performance of Lumen reflections. Increasing the value will make the bilateral filter more tolerant to normal angle differences, potentially smoothing out reflections more but at the cost of potentially losing some detail.

Best practices when using this variable include:

  1. Adjusting it in small increments to find the right balance between reflection quality and performance.
  2. Testing the changes in various lighting conditions and with different types of surfaces to ensure consistent results.
  3. Considering the impact on overall rendering performance, as bilateral filtering can be computationally expensive.

Regarding the associated variable GLumenReflectionBilateralFilterNormalAngleThresholdScale:

This C++ variable directly holds the value set by the r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale console variable. It is used in the RenderLumenReflections function of the FDeferredShadingSceneRenderer class to set up the parameters for the reflection rendering pass.

The purpose of this associated variable is to provide fast, thread-safe access to the current value of the normal angle threshold scale within the rendering code.

This variable is set automatically by the engine’s console variable system and should not be modified directly in code. Instead, developers should use the r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale console variable to change its value.

When working with this variable, developers should be aware that it’s marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it can be changed for scalability purposes and is safe to modify from the render thread.

Best practices for this associated variable include:

  1. Treating it as read-only in most scenarios, relying on the console variable system for modifications.
  2. Being aware of its usage in performance-critical rendering code and considering its impact when profiling or optimizing Lumen reflections.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:230

Scope: file

Source code excerpt:

float GLumenReflectionBilateralFilterNormalAngleThresholdScale = 1.0f;
FAutoConsoleVariableRef CVarLumenReflectionBilateralFilterNormalAngleThresholdScale(
	TEXT("r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale"),
	GLumenReflectionBilateralFilterNormalAngleThresholdScale,
	TEXT("Scales the Normal angle threshold of the bilateral filter"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GLumenReflectionBilateralFilterStrongBlurVarianceThreshold = .5f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:228

Scope: file

Source code excerpt:

	);

float GLumenReflectionBilateralFilterNormalAngleThresholdScale = 1.0f;
FAutoConsoleVariableRef CVarLumenReflectionBilateralFilterNormalAngleThresholdScale(
	TEXT("r.Lumen.Reflections.BilateralFilter.NormalAngleThresholdScale"),
	GLumenReflectionBilateralFilterNormalAngleThresholdScale,
	TEXT("Scales the Normal angle threshold of the bilateral filter"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GLumenReflectionBilateralFilterStrongBlurVarianceThreshold = .5f;
FAutoConsoleVariableRef CVarLumenReflectionBilateralFilterStrongBlurVarianceThreshold(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:1317

Scope (from outer to inner):

file
function     FRDGTextureRef FDeferredShadingSceneRenderer::RenderLumenReflections

Source code excerpt:

			PassParameters->BilateralFilterNumSamples = GLumenReflectionBilateralFilterNumSamples;
			PassParameters->BilateralFilterDepthWeightScale = GLumenReflectionBilateralFilterDepthWeightScale;
			PassParameters->BilateralFilterNormalAngleThresholdScale = GLumenReflectionBilateralFilterNormalAngleThresholdScale;
			PassParameters->BilateralFilterStrongBlurVarianceThreshold = GLumenReflectionBilateralFilterStrongBlurVarianceThreshold;
			PassParameters->View = View.ViewUniformBuffer;
			PassParameters->SceneTexturesStruct = SceneTextures.UniformBuffer;
			PassParameters->Substrate = Substrate::BindSubstrateGlobalUniformParameters(View);
			PassParameters->ReflectionTracingParameters = ReflectionTracingParameters;
			PassParameters->ReflectionTileParameters = ReflectionTileParameters;