r.AmbientOcclusion.Denoiser.TemporalAccumulation

r.AmbientOcclusion.Denoiser.TemporalAccumulation

#Overview

name: r.AmbientOcclusion.Denoiser.TemporalAccumulation

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.AmbientOcclusion.Denoiser.TemporalAccumulation is to control the temporal accumulation of samples for the Ambient Occlusion (AO) denoiser in Unreal Engine’s rendering system. This setting variable is part of the screen space denoising subsystem, which is responsible for improving the quality of various rendering effects, including ambient occlusion.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the screen space denoiser component. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/ScreenSpaceDenoise.cpp.

The value of this variable is set as a console variable (CVar) with a default value of 1. It can be modified at runtime through the console or configuration files.

This variable interacts with other AO denoiser settings, such as CVarAOHistoryConvolutionSampleCount and CVarAOHistoryConvolutionKernelSpreadFactor, which are part of the same denoising process.

Developers must be aware that this variable affects the performance and quality of the ambient occlusion effect. Enabling temporal accumulation (value set to 1) can improve the quality of the AO by reducing noise over multiple frames, but it may also introduce some performance overhead.

Best practices when using this variable include:

  1. Consider the trade-off between visual quality and performance when enabling or disabling temporal accumulation.
  2. Test the impact of this setting in various scenarios to ensure it meets the desired balance of quality and performance for your specific project.
  3. Be mindful of how this setting interacts with other AO and denoising settings for optimal results.

Regarding the associated variable CVarAOTemporalAccumulation:

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

This variable is used within the Renderer module, specifically in the FDefaultScreenSpaceDenoiser class, which implements the IScreenSpaceDenoiser interface.

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

CVarAOTemporalAccumulation interacts directly with the denoising process in the DenoiseAmbientOcclusion function, where its value determines whether temporal accumulation is used in the AO denoising settings.

Developers should be aware that accessing this variable should be done on the render thread, as indicated by the use of GetValueOnRenderThread() in the code.

Best practices for using CVarAOTemporalAccumulation include:

  1. Always access its value on the render thread to avoid threading issues.
  2. Use it in conjunction with other AO denoising settings for a comprehensive control over the denoising process.
  3. Consider exposing this setting in user-facing graphics options if fine-tuning of AO quality is desired in your project.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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

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

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

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

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

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FAmbientOcclusionOutputs DenoiseAmbientOcclusion

Source code excerpt:

		Settings.PreConvolutionCount = CVarAOPreConvolutionCount.GetValueOnRenderThread();
		Settings.KernelSpreadFactor = CVarAOKernelSpreadFactor.GetValueOnRenderThread();
		Settings.bUseTemporalAccumulation = CVarAOTemporalAccumulation.GetValueOnRenderThread() != 0;
		Settings.HistoryConvolutionSampleCount = CVarAOHistoryConvolutionSampleCount.GetValueOnRenderThread();
		Settings.HistoryConvolutionKernelSpreadFactor = CVarAOHistoryConvolutionKernelSpreadFactor.GetValueOnRenderThread();
		Settings.MaxInputSPP = RayTracingConfig.RayCountPerPixel;

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