r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated

r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated

#Overview

name: r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated

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.ReSTIRGather.Temporal.MaxFramesAccumulated is to control the temporal accumulation of lighting in Unreal Engine 5’s Lumen global illumination system, specifically for the ReSTIR (Resampled Importance Sampling for Real-Time Ray Tracing) gather pass.

This setting variable is part of the Lumen rendering system in Unreal Engine 5. It is used in the ReSTIR gather pass, which is a technique for improving the quality and performance of real-time global illumination.

The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. It can be modified at runtime or set in configuration files.

The associated variable GLumenReSTIRGatherTemporalMaxFramesAccumulated directly interacts with it. This C++ variable holds the actual value used in the rendering code.

Developers must be aware that this variable affects the trade-off between lighting update speed and visual stability. Lower values will cause lighting changes to propagate faster but may introduce more flickering due to noise.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of the scene and the desired balance between responsiveness and stability.
  2. Testing different values to find the optimal setting for your specific use case.
  3. Considering the interaction with other Lumen settings, particularly those related to temporal accumulation and filtering.

Regarding the associated variable GLumenReSTIRGatherTemporalMaxFramesAccumulated:

The purpose of this variable is to store the actual value used in the rendering code for the maximum number of frames accumulated in the temporal filter.

It is used directly in the Lumen ReSTIR gather pass of the rendering system.

The value of this variable is set initially to 10.0f and can be modified through the console variable system.

This variable interacts directly with the r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated console variable and is used in the DispatchTemporalAccumulation function to calculate the final MaxFramesAccumulated value.

Developers should be aware that this variable is scaled based on the LumenFinalGatherLightingUpdateSpeed post-processing setting and whether the scene is currently being edited.

Best practices include monitoring this variable’s actual value during runtime to understand how it’s being affected by other settings and scene conditions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReSTIRGather.cpp:197

Scope: file

Source code excerpt:

float GLumenReSTIRGatherTemporalMaxFramesAccumulated = 10.0f;
FAutoConsoleVariableRef CVarLumenReSTIRGatherTemporalMaxFramesAccumulated(
	TEXT("r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated"),
	GLumenReSTIRGatherTemporalMaxFramesAccumulated,
	TEXT("Lower values cause the temporal filter to propagate lighting changes faster, but also increase flickering from noise."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenReSTIRGatherBilateralFilter = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReSTIRGather.cpp:195

Scope: file

Source code excerpt:

);

float GLumenReSTIRGatherTemporalMaxFramesAccumulated = 10.0f;
FAutoConsoleVariableRef CVarLumenReSTIRGatherTemporalMaxFramesAccumulated(
	TEXT("r.Lumen.ReSTIRGather.Temporal.MaxFramesAccumulated"),
	GLumenReSTIRGatherTemporalMaxFramesAccumulated,
	TEXT("Lower values cause the temporal filter to propagate lighting changes faster, but also increase flickering from noise."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenReSTIRGatherBilateralFilter = 1;
FAutoConsoleVariableRef CVarLumenReSTIRGatherBilateralFilter(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReSTIRGather.cpp:812

Scope (from outer to inner):

file
function     void DispatchTemporalAccumulation
lambda-function

Source code excerpt:

						const float MaxFramesAccumulatedScale = 1.0f / FMath::Sqrt(FMath::Clamp(View.FinalPostProcessSettings.LumenFinalGatherLightingUpdateSpeed, .5f, 8.0f));
						const float EditingScale = View.Family->bCurrentlyBeingEdited ? .5f : 1.0f;
						PassParameters->MaxFramesAccumulated = FMath::RoundToInt(GLumenReSTIRGatherTemporalMaxFramesAccumulated * MaxFramesAccumulatedScale * EditingScale);
						PassParameters->HistoryScreenPositionScaleBias = *DiffuseIndirectHistoryScreenPositionScaleBias;

						// History uses HistoryDepth which has the same resolution than SceneTextures (no extented/overflow space)
						const FIntPoint BufferSize = SceneTextures.Config.Extent;
						const FVector2D InvBufferSize(1.0f / BufferSize.X, 1.0f / BufferSize.Y);