r.Lumen.TranslucencyVolume.Temporal.HistoryWeight

r.Lumen.TranslucencyVolume.Temporal.HistoryWeight

#Overview

name: r.Lumen.TranslucencyVolume.Temporal.HistoryWeight

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.TranslucencyVolume.Temporal.HistoryWeight is to control the temporal stability of the translucency volume lighting in Unreal Engine 5’s Lumen global illumination system. It determines how much weight is given to the history value each frame, balancing between visible jittering and responsiveness in the translucency lighting.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine 5’s rendering module. Specifically, it’s utilized in the translucency volume lighting calculations, which are part of the global illumination system.

The value of this variable is set through the Unreal Engine console variable system. It’s declared as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands or configuration files.

The associated variable GTranslucencyVolumeHistoryWeight directly interacts with r.Lumen.TranslucencyVolume.Temporal.HistoryWeight. They share the same value, with GTranslucencyVolumeHistoryWeight being the C++ variable that’s actually used in the rendering code.

Developers must be aware that this variable affects the trade-off between stability and responsiveness in translucent object lighting. A higher value will result in more stable lighting but slower response to changes, while a lower value will make lighting more responsive but potentially more jittery.

Best practices when using this variable include:

  1. Fine-tuning the value based on the specific needs of the scene and the desired visual quality.
  2. Testing the effects of different values in various lighting conditions and with different types of translucent objects.
  3. Considering the performance implications, as higher temporal stability might come at the cost of increased computational load.

Regarding the associated variable GTranslucencyVolumeHistoryWeight:

The purpose of GTranslucencyVolumeHistoryWeight is to store the actual value used in the rendering calculations for the translucency volume history weight.

This variable is used directly in the Lumen translucency volume lighting system, specifically in the ComputeLumenTranslucencyGIVolume function of the FDeferredShadingSceneRenderer class.

The value of GTranslucencyVolumeHistoryWeight is set by the console variable system through r.Lumen.TranslucencyVolume.Temporal.HistoryWeight.

It interacts directly with the rendering pass parameters, being assigned to PassParameters->HistoryWeight in the translucency GI volume computation.

Developers should be aware that modifying GTranslucencyVolumeHistoryWeight directly in code is not recommended, as its value is intended to be controlled through the console variable system.

Best practices for GTranslucencyVolumeHistoryWeight include:

  1. Accessing its value when needed in rendering code rather than storing it locally.
  2. Ensuring that any code depending on this value is prepared to handle potential runtime changes.
  3. Using the console variable r.Lumen.TranslucencyVolume.Temporal.HistoryWeight for adjusting the value during development or at runtime, rather than modifying the variable directly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:108

Scope: file

Source code excerpt:

float GTranslucencyVolumeHistoryWeight = .9f;
FAutoConsoleVariableRef CVarTranslucencyVolumeHistoryWeight(
	TEXT("r.Lumen.TranslucencyVolume.Temporal.HistoryWeight"),
	GTranslucencyVolumeHistoryWeight,
	TEXT("How much the history value should be weighted each frame.  This is a tradeoff between visible jittering and responsiveness."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GTranslucencyVolumeTraceStepFactor = 2;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:106

Scope: file

Source code excerpt:

	);

float GTranslucencyVolumeHistoryWeight = .9f;
FAutoConsoleVariableRef CVarTranslucencyVolumeHistoryWeight(
	TEXT("r.Lumen.TranslucencyVolume.Temporal.HistoryWeight"),
	GTranslucencyVolumeHistoryWeight,
	TEXT("How much the history value should be weighted each frame.  This is a tradeoff between visible jittering and responsiveness."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GTranslucencyVolumeTraceStepFactor = 2;
FAutoConsoleVariableRef CVarTranslucencyVolumeTraceStepFactor(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:893

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::ComputeLumenTranslucencyGIVolume

Source code excerpt:

					&& TranslucencyGIVolumeHistory0->Desc == LumenTranslucencyGIDesc0;

				PassParameters->HistoryWeight = GTranslucencyVolumeHistoryWeight;
				const int32 PreviousFrameIndexOffset = View.bStatePrevViewInfoIsReadOnly ? 0 : 1;
				PassParameters->PreviousFrameJitterOffset = (FVector3f)TranslucencyVolumeTemporalRandom(View.ViewState ? View.ViewState->GetFrameIndex() - PreviousFrameIndexOffset : 0);
				PassParameters->UnjitteredPrevWorldToClip = FMatrix44f(View.PrevViewInfo.ViewMatrices.GetViewMatrix() * View.PrevViewInfo.ViewMatrices.ComputeProjectionNoAAMatrix());		// LWC_TODO: Precision loss?
				PassParameters->TranslucencyGIHistory0 = TranslucencyGIVolumeHistory0;
				PassParameters->TranslucencyGIHistory1 = TranslucencyGIVolumeHistory1;
				PassParameters->TranslucencyGIHistorySampler = TStaticSamplerState<SF_Trilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();