r.ManyLights.Temporal.MaxFramesAccumulated

r.ManyLights.Temporal.MaxFramesAccumulated

#Overview

name: r.ManyLights.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.ManyLights.Temporal.MaxFramesAccumulated is to control the maximum number of frames accumulated in the temporal history for the Many Lights rendering system in Unreal Engine 5. This setting is specifically used for managing the trade-off between reducing ghosting artifacts and minimizing noise in the rendered image.

This setting variable is primarily used by the Renderer module, specifically within the Many Lights rendering system. Based on the callsites, it’s clear that this variable is utilized in the FDeferredShadingSceneRenderer class, which is responsible for deferred shading calculations.

The value of this variable is set through a console variable (CVar) system, allowing it to be modified at runtime. The default value is set to 8 frames, as seen in the source code.

The associated variable CVarManyLightsTemporalMaxFramesAccumulated directly interacts with r.ManyLights.Temporal.MaxFramesAccumulated. They share the same value and purpose.

Developers should be aware that:

  1. Lower values will result in less ghosting artifacts but more noise in the final image.
  2. Higher values will produce smoother results but may introduce more ghosting.
  3. The value is clamped to be non-negative in the code (FMath::Max(…, 0.0f)).

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of the scene and the desired balance between image stability and responsiveness to changes.
  2. Testing different values to find the optimal setting for your particular use case.
  3. Considering the performance impact of higher values, as they may require more memory to store the temporal history.

Regarding the associated variable CVarManyLightsTemporalMaxFramesAccumulated:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:47

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsTemporalMaxFramesAccumulated(
	TEXT("r.ManyLights.Temporal.MaxFramesAccumulated"),
	8,
	TEXT("Max history length when accumulating frames. Lower values have less ghosting, but more noise."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarManyLightsTemporalNeighborhoodClampScale(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:46

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsTemporalMaxFramesAccumulated(
	TEXT("r.ManyLights.Temporal.MaxFramesAccumulated"),
	8,
	TEXT("Max history length when accumulating frames. Lower values have less ghosting, but more noise."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:762

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderManyLights

Source code excerpt:

		ManyLightsParameters.TileDataStride = TileDataStride;
		ManyLightsParameters.DownsampledTileDataStride = DownsampledTileDataStride;
		ManyLightsParameters.TemporalMaxFramesAccumulated = FMath::Max(CVarManyLightsTemporalMaxFramesAccumulated.GetValueOnRenderThread(), 0.0f);
		ManyLightsParameters.TemporalNeighborhoodClampScale = CVarManyLightsTemporalNeighborhoodClampScale.GetValueOnRenderThread();
		ManyLightsParameters.TemporalAdvanceFrame = View.ViewState && !View.bStatePrevViewInfoIsReadOnly ? 1 : 0;
		ManyLightsParameters.DebugMode = ManyLights::GetDebugMode();
		ManyLightsParameters.DebugLightId = INDEX_NONE;

		if (bDebug)