r.Shadow.Denoiser.TemporalAccumulation

r.Shadow.Denoiser.TemporalAccumulation

#Overview

name: r.Shadow.Denoiser.TemporalAccumulation

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Shadow.Denoiser.TemporalAccumulation is to control the temporal accumulation feature in the shadow denoising process within Unreal Engine’s rendering system. This setting variable is primarily used in the screen space denoising subsystem, which is part of the renderer module.

The Unreal Engine subsystem that relies on this setting variable is the renderer, specifically the screen space denoising component. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp” where the variable is defined and used.

The value of this variable is set as a console variable with a default value of 1. It can be changed at runtime through the console or programmatically.

This variable interacts with other shadow denoising-related variables such as CVarShadowReconstructionSampleCount, CVarShadowPreConvolutionCount, and CVarShadowHistoryConvolutionSampleCount. These variables work together to configure various aspects of the shadow denoising process.

Developers must be aware that this variable affects the performance and quality of shadow rendering. Enabling temporal accumulation (value != 0) can improve shadow quality over time but may have performance implications.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance between shadow quality and performance for your specific use case.
  2. Considering the target hardware when adjusting this setting, as lower-end devices may benefit from disabling temporal accumulation for performance reasons.
  3. Using this in conjunction with other shadow denoising settings for best results.

Regarding the associated variable CVarShadowTemporalAccumulation:

The purpose of CVarShadowTemporalAccumulation is to provide programmatic access to the r.Shadow.Denoiser.TemporalAccumulation setting within the C++ code of the engine.

This variable is used directly in the renderer’s screen space denoising system, specifically in the FDefaultScreenSpaceDenoiser class.

The value of this variable is set when the console variable r.Shadow.Denoiser.TemporalAccumulation is initialized or changed.

It interacts with other denoising-related variables and is used to configure the denoising process in methods like DenoiseShadowVisibilityMasks and DenoisePolychromaticPenumbraHarmonics.

Developers should be aware that this variable is accessed on the render thread, so any modifications should be thread-safe.

Best practices include using the GetValueOnRenderThread() method to access its value within render thread operations, and avoiding direct modification of this variable outside of the appropriate engine systems.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:33

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarShadowTemporalAccumulation(
	TEXT("r.Shadow.Denoiser.TemporalAccumulation"), 1,
	TEXT(""),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadowHistoryConvolutionSampleCount(
	TEXT("r.Shadow.Denoiser.HistoryConvolutionSamples"), 1,
	TEXT("Number of samples to use to convolve the history over time."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:32

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadowTemporalAccumulation(
	TEXT("r.Shadow.Denoiser.TemporalAccumulation"), 1,
	TEXT(""),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarShadowHistoryConvolutionSampleCount(
	TEXT("r.Shadow.Denoiser.HistoryConvolutionSamples"), 1,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:2266

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     virtual void DenoiseShadowVisibilityMasks

Source code excerpt:

		Settings.ReconstructionSamples = FMath::Clamp(CVarShadowReconstructionSampleCount.GetValueOnRenderThread(), 1, kStackowiakMaxSampleCountPerSet);
		Settings.PreConvolutionCount = CVarShadowPreConvolutionCount.GetValueOnRenderThread();
		Settings.bUseTemporalAccumulation = CVarShadowTemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.HistoryConvolutionSampleCount = CVarShadowHistoryConvolutionSampleCount.GetValueOnRenderThread();
		Settings.SignalBatchSize = InputParameterCount;

		for (int32 BatchedSignalId = 0; BatchedSignalId < InputParameterCount; BatchedSignalId++)
		{
			Settings.MaxInputSPP = FMath::Max(Settings.MaxInputSPP, InputParameters[BatchedSignalId].RayTracingConfig.RayCountPerPixel);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp:2513

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FPolychromaticPenumbraOutputs DenoisePolychromaticPenumbraHarmonics

Source code excerpt:

			Settings.SignalProcessing = ESignalProcessing::PolychromaticPenumbraHarmonic;
			Settings.bEnableReconstruction = false;
			Settings.bUseTemporalAccumulation = CVarShadowTemporalAccumulation.GetValueOnRenderThread() != 0;

			TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;
			TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> NewHistories;
			PrevHistories[0] = &PreviousViewInfos->PolychromaticPenumbraHarmonicsHistory;
			NewHistories[0] = View.ViewState ? &View.ViewState->PrevFrameViewInfo.PolychromaticPenumbraHarmonicsHistory : nullptr;