r.AmbientOcclusion.Denoiser.HistoryConvolution.SampleCount

r.AmbientOcclusion.Denoiser.HistoryConvolution.SampleCount

#Overview

name: r.AmbientOcclusion.Denoiser.HistoryConvolution.SampleCount

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.HistoryConvolution.SampleCount is to control the number of samples used for the history post-filter in the Ambient Occlusion (AO) denoising process. This setting variable is part of Unreal Engine 5’s rendering system, specifically the screen space denoising subsystem.

This setting variable is primarily used in the Renderer module, particularly in the screen space denoising component. It’s employed in the ambient occlusion denoising process to improve the quality of the final rendered image by reducing noise artifacts.

The value of this variable is set through a console variable (CVar) system. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime. The default value is set to 1, but the comment suggests that 16 is a more typical value.

The associated variable CVarAOHistoryConvolutionSampleCount directly interacts with this setting. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the performance-quality trade-off in the AO denoising process. A higher sample count will likely produce better quality results but at the cost of increased computational overhead.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between image quality and performance for your specific use case.
  2. Consider the target hardware when setting this value, as higher-end systems may be able to handle higher sample counts.
  3. Use in conjunction with other AO denoising settings for best results.

Regarding the associated variable CVarAOHistoryConvolutionSampleCount:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<float> CVarAOHistoryConvolutionKernelSpreadFactor(
	TEXT("r.AmbientOcclusion.Denoiser.HistoryConvolution.KernelSpreadFactor"), 7,
	TEXT("Multiplication factor applied on the kernel sample offset (default = 7)."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	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)."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarAOHistoryConvolutionKernelSpreadFactor(
	TEXT("r.AmbientOcclusion.Denoiser.HistoryConvolution.KernelSpreadFactor"), 7,

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FAmbientOcclusionOutputs DenoiseAmbientOcclusion

Source code excerpt:

		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;
		PrevHistories[0] = &PreviousViewInfos->AmbientOcclusionHistory;