r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount

r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount

#Overview

name: r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount

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.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount is to control the number of samples used for the history post-filter in the Global Illumination denoiser system. This setting variable is part of Unreal Engine’s rendering system, specifically the screen space denoising process for global illumination.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the screen space denoising subsystem. It affects the quality and performance of the global illumination denoising process.

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

The associated variable CVarGIHistoryConvolutionSampleCount directly interacts with r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount. They share the same value and purpose.

Developers must be aware that increasing this value will likely improve the quality of the denoised global illumination at the cost of increased computational overhead. It’s important to balance visual quality with performance requirements.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between quality and performance for your specific project.
  2. Consider adjusting this value dynamically based on the scene complexity or performance targets.
  3. Use in conjunction with other denoising parameters for best results.

Regarding the associated variable CVarGIHistoryConvolutionSampleCount:

The purpose of CVarGIHistoryConvolutionSampleCount is to provide a programmatic interface to access and modify the r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount value within the C++ code of the engine.

This variable is used in the FDefaultScreenSpaceDenoiser class, specifically in the DenoiseDiffuseIndirect and DenoiseSkyLight functions. It’s used to set the HistoryConvolutionSampleCount in the denoiser settings.

The value of this variable is set through the console variable system and can be accessed using the GetValueOnRenderThread() method.

CVarGIHistoryConvolutionSampleCount interacts directly with r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount, as they represent the same setting.

Developers should be aware that this variable is used in render thread-safe contexts, as indicated by the ECVF_RenderThreadSafe flag.

Best practices for using this variable include:

  1. Accessing its value only on the render thread using GetValueOnRenderThread().
  2. Considering caching the value if it’s accessed frequently, to avoid potential performance overhead from repeated console variable lookups.
  3. Using it in conjunction with other denoiser settings for a comprehensive approach to global illumination quality.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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

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

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

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

static TAutoConsoleVariable<float> CVarGIHistoryConvolutionKernelSpreadFactor(
	TEXT("r.GlobalIllumination.Denoiser.HistoryConvolution.KernelSpreadFactor"), 3,

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FSSDSignalTextures DenoiseDiffuseIndirect

Source code excerpt:

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

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

Scope (from outer to inner):

file
class        class FDefaultScreenSpaceDenoiser : public IScreenSpaceDenoiser
function     FDiffuseIndirectOutputs DenoiseSkyLight

Source code excerpt:

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