r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance

r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance

#Overview

name: r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance

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.Temporal.NeighborhoodClampExpandWithResolveVariance is to control the expansion of the neighborhood variance in Lumen’s reflection system. It is used to allow some ghosting in noisy areas to avoid flickering when the camera is still, specifically when the bilateral filter is enabled.

This setting variable is primarily used in the Lumen reflection system, which is part of Unreal Engine’s rendering subsystem. It is specifically utilized in the temporal reprojection process for reflections.

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

The associated variable GLumenReflectionNeighborhoodClampExpandWithResolveVariance interacts directly with this console variable. It holds the actual value used in the rendering code.

Developers must be aware that this variable only has an effect when the bilateral filter is enabled for Lumen reflections. It affects the balance between ghosting and flickering in reflections, particularly in noisy areas or when the camera is stationary.

Best practices when using this variable include:

  1. Fine-tuning the value based on the specific scene and desired visual quality.
  2. Testing with different camera movements to ensure a good balance between ghosting reduction and flickering prevention.
  3. Using it in conjunction with other Lumen reflection settings for optimal results.

Regarding the associated variable GLumenReflectionNeighborhoodClampExpandWithResolveVariance:

This is the actual float variable used in the rendering code to store the value set by the console variable. It is used directly in the FReflectionTemporalReprojectionCS::FParameters struct, which is part of the temporal reprojection compute shader for reflections.

The value of GLumenReflectionNeighborhoodClampExpandWithResolveVariance is assigned to the NeighborhoodClampExpandWithResolveVariance parameter in the shader. This parameter determines how much the neighborhood variance is expanded based on the resolve variance, which in turn affects the temporal stability of the reflections.

Developers should be aware that modifying the console variable r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance will directly affect the value of GLumenReflectionNeighborhoodClampExpandWithResolveVariance, and consequently, the behavior of the reflection temporal reprojection shader.

#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:126

Scope: file

Source code excerpt:

float GLumenReflectionNeighborhoodClampExpandWithResolveVariance = .1f;
FAutoConsoleVariableRef CVarLumenReflectionNeighborhoodClampExpandWithResolveVariance(
	TEXT("r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance"),
	GLumenReflectionNeighborhoodClampExpandWithResolveVariance,
	TEXT("Fraction of the resolve variance to use to expand the neighborhood variance.  This allows some ghosting in noisy areas to avoid flickering when the camera is still.  Only works when the bilateral filter is enabled."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenReflectionHistoryDistanceThreshold = .03f;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

float GLumenReflectionNeighborhoodClampExpandWithResolveVariance = .1f;
FAutoConsoleVariableRef CVarLumenReflectionNeighborhoodClampExpandWithResolveVariance(
	TEXT("r.Lumen.Reflections.Temporal.NeighborhoodClampExpandWithResolveVariance"),
	GLumenReflectionNeighborhoodClampExpandWithResolveVariance,
	TEXT("Fraction of the resolve variance to use to expand the neighborhood variance.  This allows some ghosting in noisy areas to avoid flickering when the camera is still.  Only works when the bilateral filter is enabled."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLumenReflectionHistoryDistanceThreshold = .03f;
FAutoConsoleVariableRef CVarLumenReflectionHistoryDistanceThreshold(

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

Scope (from outer to inner):

file
function     void UpdateHistoryReflections

Source code excerpt:

				(HistoryViewRect->Max.Y - 0.5f) * InvBufferSize.Y);
			PassParameters->MaxFramesAccumulated = GLumenReflectionTemporalMaxFramesAccumulated;
			PassParameters->NeighborhoodClampExpandWithResolveVariance = GLumenReflectionNeighborhoodClampExpandWithResolveVariance;

			PassParameters->VelocityTexture = VelocityTexture;
			PassParameters->VelocityTextureSampler = TStaticSamplerState<SF_Bilinear>::GetRHI();
			PassParameters->ResolvedReflections = ResolvedReflections;
			PassParameters->ResolvedReflectionsDepth = ResolvedReflectionsDepth;
			PassParameters->ResolveVariance = ResolveVariance;