r.ManyLights.Temporal

r.ManyLights.Temporal

#Overview

name: r.ManyLights.Temporal

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 is to control whether temporal accumulation is used for the shadow mask in the Many Lights rendering system.

This setting variable is primarily used in the rendering system of Unreal Engine 5, specifically within the Many Lights module. Based on the callsites, it’s evident that this variable is utilized in the Renderer module, particularly in the ManyLights.cpp file.

The value of this variable is set through a console variable (CVarManyLightsTemporal) with a default value of 1, meaning temporal accumulation for the shadow mask is enabled by default. Developers can modify this value at runtime using console commands or through project settings.

The associated variable CVarManyLightsTemporal directly interacts with r.ManyLights.Temporal. It’s the C++ representation of the console variable and is used to retrieve the current value of the setting.

Developers should be aware that this variable affects the quality and performance of shadow rendering in scenes with many lights. Enabling temporal accumulation (value set to 1) can improve the quality of shadows by reducing noise and flickering, but it may have a slight performance cost.

Best practices when using this variable include:

  1. Consider the trade-off between visual quality and performance when deciding whether to enable or disable it.
  2. Test the impact of enabling/disabling this feature in various lighting scenarios to determine the optimal setting for your project.
  3. Be cautious when changing this value dynamically during gameplay, as it may cause visible changes in shadow quality.

Regarding the associated variable CVarManyLightsTemporal:

The purpose of CVarManyLightsTemporal is to provide a programmatic interface to the r.ManyLights.Temporal setting within the C++ code of the engine.

This variable is used in the Renderer module, specifically in the Many Lights system. It allows the engine to check the current state of the temporal accumulation setting for shadow masks.

The value of CVarManyLightsTemporal is set when the engine initializes the console variables, but it can be changed at runtime through console commands or project settings that modify r.ManyLights.Temporal.

CVarManyLightsTemporal directly interacts with r.ManyLights.Temporal, essentially serving as its C++ representation.

Developers should be aware that this variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it’s safe to modify on the render thread and can be used for scalability settings.

Best practices for using CVarManyLightsTemporal include:

  1. Use GetValueOnRenderThread() when accessing its value in render thread code.
  2. Consider caching the value if it’s accessed frequently in performance-critical sections.
  3. Be aware of potential performance implications when changing this value, especially in scenes with many lights.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsTemporal(
	TEXT("r.ManyLights.Temporal"),
	1,
	TEXT("Whether to use temporal accumulation for shadow mask."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarManyLightsTemporalMaxFramesAccumulated(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsTemporal(
	TEXT("r.ManyLights.Temporal"),
	1,
	TEXT("Whether to use temporal accumulation for shadow mask."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderManyLights

Source code excerpt:

		TEXT("ManyLights.LightSampleRayDistance"));
	
	bool bTemporal = CVarManyLightsTemporal.GetValueOnRenderThread() != 0;
	FVector4f HistoryScreenPositionScaleBias = FVector4f(0.0f, 0.0f, 0.0f, 0.0f);
	FVector4f HistoryUVMinMax = FVector4f(0.0f, 0.0f, 0.0f, 0.0f);
	FRDGTextureRef DiffuseLightingAndSecondMomentHistory = nullptr;
	FRDGTextureRef SpecularLightingAndSecondMomentHistory = nullptr;
	FRDGTextureRef SceneDepthHistory = nullptr;
	FRDGTextureRef NumFramesAccumulatedHistory = nullptr;