r.Lumen.ReSTIRGather.TemporalResampling

r.Lumen.ReSTIRGather.TemporalResampling

#Overview

name: r.Lumen.ReSTIRGather.TemporalResampling

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.TemporalResampling is to control whether temporal resampling is applied to reservoirs in the Lumen ReSTIR (Resampled Importance Sampling for Real-Time Indirect Illumination) gather process. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically the ReSTIR implementation for efficient light sampling.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized in the LumenReSTIRGather.cpp file, which is part of the Renderer module.

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

The associated variable GLumenReSTIRTemporalResampling directly interacts with this setting. They share the same value, with GLumenReSTIRTemporalResampling being the actual integer variable used in the code logic.

Developers should be aware that:

  1. This setting affects the quality and performance of global illumination in scenes using Lumen.
  2. Enabling temporal resampling (default) can improve the stability and quality of lighting over time, but may have a performance cost.
  3. This setting is marked with ECVF_Scalability, indicating it can be adjusted for different scalability presets.

Best practices when using this variable include:

  1. Leaving it enabled (default) for most scenarios to benefit from temporal stability in lighting.
  2. Consider disabling it in performance-critical situations where the temporal stability is less important.
  3. Test the visual impact and performance with this setting enabled and disabled to find the best balance for your specific project.

Regarding the associated variable GLumenReSTIRTemporalResampling:

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

Scope: file

Source code excerpt:

int32 GLumenReSTIRTemporalResampling = 1;
FAutoConsoleVariableRef CVarLumenReSTIRTemporalResampling(
	TEXT("r.Lumen.ReSTIRGather.TemporalResampling"),
	GLumenReSTIRTemporalResampling,
	TEXT("Whether to do a temporal resampling pass on the reservoirs"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GLumenReSTIRValidateTemporalReservoirsEveryNFrames = 0;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

int32 GLumenReSTIRTemporalResampling = 1;
FAutoConsoleVariableRef CVarLumenReSTIRTemporalResampling(
	TEXT("r.Lumen.ReSTIRGather.TemporalResampling"),
	GLumenReSTIRTemporalResampling,
	TEXT("Whether to do a temporal resampling pass on the reservoirs"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

int32 GLumenReSTIRValidateTemporalReservoirsEveryNFrames = 0;
FAutoConsoleVariableRef CVarLumenReSTIRTemporalResamplingValidate(

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

Scope (from outer to inner):

file
function     FSSDSignalTextures FDeferredShadingSceneRenderer::RenderLumenReSTIRGather

Source code excerpt:

	}

	const bool bUseTemporalResampling = GLumenReSTIRTemporalResampling != 0 && View.ViewState;

	if (bUseTemporalResampling)
	{
		FReSTIRTemporalResamplingState& TemporalResamplingState = View.ViewState->Lumen.ReSTIRGatherState.TemporalResamplingState;

		FReservoirTextures TemporalReservoirTextures = AllocateReservoirTextures(GraphBuilder, ReservoirBufferSize);