r.GlobalIllumination.Denoiser.TemporalAccumulation

r.GlobalIllumination.Denoiser.TemporalAccumulation

#Overview

name: r.GlobalIllumination.Denoiser.TemporalAccumulation

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.GlobalIllumination.Denoiser.TemporalAccumulation is to control whether the Global Illumination (GI) denoiser accumulates samples over multiple frames. This setting is part of the rendering system, specifically the Global Illumination and denoising subsystem.

This setting variable is used in the Unreal Engine’s rendering module, particularly in the screen space denoising system. It’s primarily utilized in the FDefaultScreenSpaceDenoiser class, which is responsible for denoising various rendering effects, including diffuse indirect lighting, sky light, and screen space diffuse indirect lighting.

The value of this variable is set through the console variable system (CVarGITemporalAccumulation). It’s a boolean value, where 1 enables temporal accumulation and 0 disables it.

The associated variable CVarGITemporalAccumulation directly interacts with this setting. It’s used to retrieve the current value of the setting in the render thread.

Developers should be aware that enabling temporal accumulation can improve the quality of Global Illumination by reducing noise over time, but it may also introduce some latency in responding to changes in lighting or scene geometry. It’s particularly important for real-time GI solutions.

Best practices when using this variable include:

  1. Enable it for better quality in static or slowly changing scenes.
  2. Consider disabling it for highly dynamic scenes where rapid changes in lighting are crucial.
  3. Test the performance impact, as temporal accumulation may have a slight performance cost.
  4. Use in conjunction with other GI and denoising settings for optimal results.

The associated variable CVarGITemporalAccumulation is the actual console variable that stores and provides access to the r.GlobalIllumination.Denoiser.TemporalAccumulation setting. It’s defined as a static TAutoConsoleVariable and is used throughout the denoising code to determine whether temporal accumulation should be applied. The same considerations and best practices apply to this variable as they do to the setting itself.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarGITemporalAccumulation(
	TEXT("r.GlobalIllumination.Denoiser.TemporalAccumulation"), 1,
	TEXT("Accumulates the samples over multiple frames."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarGIHistoryConvolutionSampleCount(
	TEXT("r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount"), 1,
	TEXT("Number of samples to use for history post filter (default = 1)."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarGITemporalAccumulation(
	TEXT("r.GlobalIllumination.Denoiser.TemporalAccumulation"), 1,
	TEXT("Accumulates the samples over multiple frames."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarGIHistoryConvolutionSampleCount(
	TEXT("r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount"), 1,

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FSSDSignalTextures DenoiseDiffuseIndirect

Source code excerpt:

		Settings.ReconstructionSamples = FMath::Clamp(CVarGIReconstructionSampleCount.GetValueOnRenderThread(), 1, kStackowiakMaxSampleCountPerSet);
		Settings.PreConvolutionCount = CVarGIPreConvolutionCount.GetValueOnRenderThread();
		Settings.bUseTemporalAccumulation = CVarGITemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.HistoryConvolutionSampleCount = CVarGIHistoryConvolutionSampleCount.GetValueOnRenderThread();
		Settings.HistoryConvolutionKernelSpreadFactor = CVarGIHistoryConvolutionKernelSpreadFactor.GetValueOnRenderThread();
		Settings.MaxInputSPP = Config.RayCountPerPixel;

		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;
		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> NewHistories;

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FDiffuseIndirectOutputs DenoiseSkyLight

Source code excerpt:

		Settings.ReconstructionSamples = FMath::Clamp(CVarGIReconstructionSampleCount.GetValueOnRenderThread(), 1, kStackowiakMaxSampleCountPerSet);
		Settings.PreConvolutionCount = CVarGIPreConvolutionCount.GetValueOnRenderThread();
		Settings.bUseTemporalAccumulation = CVarGITemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.HistoryConvolutionSampleCount = CVarGIHistoryConvolutionSampleCount.GetValueOnRenderThread();
		Settings.HistoryConvolutionKernelSpreadFactor = CVarGIHistoryConvolutionKernelSpreadFactor.GetValueOnRenderThread();
		Settings.MaxInputSPP = Config.RayCountPerPixel;

		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;
		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> NewHistories;

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FSSDSignalTextures DenoiseDiffuseIndirectHarmonic

Source code excerpt:

		Settings.InputResolutionFraction = 1.0f / float(CommonDiffuseParameters.DownscaleFactor);
		Settings.ReconstructionSamples = CVarGIReconstructionSampleCount.GetValueOnRenderThread();
		Settings.bUseTemporalAccumulation = CVarGITemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.MaxInputSPP = CommonDiffuseParameters.RayCountPerPixel;
		Settings.DenoisingResolutionFraction = 1.0f / float(CommonDiffuseParameters.DownscaleFactor);

		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;
		TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> NewHistories;
		PrevHistories[0] = &PreviousViewInfos->DiffuseIndirectHistory;

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FSSDSignalTextures DenoiseScreenSpaceDiffuseIndirect

Source code excerpt:

		Settings.DenoisingResolutionFraction = Config.ResolutionFraction;
		Settings.ReconstructionSamples = 8;
		Settings.bUseTemporalAccumulation = CVarGITemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.MaxInputSPP = Config.RayCountPerPixel;

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

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

Scope (from outer to inner):

file
function     FSSDSignalTextures IScreenSpaceDenoiser::DenoiseIndirectProbeHierarchy

Source code excerpt:

	Settings.SignalProcessing = ESignalProcessing::IndirectProbeHierarchy;
	Settings.bEnableReconstruction = false;
	Settings.bUseTemporalAccumulation = CVarGITemporalAccumulation.GetValueOnRenderThread() != 0;
	Settings.MaxInputSPP = 8;
	Settings.CompressedDepthTexture = CompressedDepthTexture;
	Settings.CompressedShadingModelTexture = CompressedShadingModelTexture;
	TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> PrevHistories;
	TStaticArray<FScreenSpaceDenoiserHistory*, IScreenSpaceDenoiser::kMaxBatchSize> NewHistories;
	PrevHistories[0] = &PreviousViewInfos->DiffuseIndirectHistory;