r.PathTracing.TemporalDenoiser.PatchCount

r.PathTracing.TemporalDenoiser.PatchCount

#Overview

name: r.PathTracing.TemporalDenoiser.PatchCount

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.PathTracing.TemporalDenoiser.PatchCount is to control the number of similar patches used by the Non-Local Mean algorithm for temporal denoising in the path tracing rendering system.

This setting variable is primarily used in the Unreal Engine’s rendering system, specifically in the path tracing and denoising subsystem. It is part of the temporal denoiser functionality, which is responsible for reducing noise in path-traced images over time.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 but can be changed at runtime.

The associated variable CVarPathTracingTemporalDenoiserPatchCount directly interacts with r.PathTracing.TemporalDenoiser.PatchCount. They share the same value and purpose.

Developers must be aware of the following when using this variable:

  1. The valid range is between 1 and 16.
  2. A value of 1 (default) means only the patch with the minimal distance is used and accumulated exponentially.
  3. Values greater than 1 and less than 16 enable bilateral filtering to accumulate multiple patches.

Best practices when using this variable include:

  1. Use the default value of 1 for standard denoising performance.
  2. Experiment with values between 2 and 16 to potentially improve denoising quality at the cost of performance.
  3. Be mindful of the performance impact when increasing the patch count, especially on less powerful hardware.
  4. Always clamp the value between 1 and 16 when retrieving it, as demonstrated in the GetTemporalAccumulationPatchCount() function.

Regarding the associated variable CVarPathTracingTemporalDenoiserPatchCount:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:233

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserPatchCount(
		TEXT("r.PathTracing.TemporalDenoiser.PatchCount"),
		1,
		TEXT("The number of similar patches found by Non-Local Mean to use for temporal denoising\n")
		TEXT("1: default. Accumulae the one with the minimal distance exponentially.")
		TEXT(">1 && < 16: Use bilaterial filtering to accumulate multiple patches."),
		ECVF_RenderThreadSafe
	);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:232

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserPatchCount(
		TEXT("r.PathTracing.TemporalDenoiser.PatchCount"),
		1,
		TEXT("The number of similar patches found by Non-Local Mean to use for temporal denoising\n")
		TEXT("1: default. Accumulae the one with the minimal distance exponentially.")
		TEXT(">1 && < 16: Use bilaterial filtering to accumulate multiple patches."),
		ECVF_RenderThreadSafe

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:494

Scope (from outer to inner):

file
function     static int32 GetTemporalAccumulationPatchCount

Source code excerpt:

static int32 GetTemporalAccumulationPatchCount()
{
	return FMath::Clamp(CVarPathTracingTemporalDenoiserPatchCount.GetValueOnRenderThread(), 1, 16);
}

static bool ShouldUseTotalVariation(uint32 MipLevel)
{
	return CVarPathTracingTemporalDenoiserTotalVariation.GetValueOnRenderThread() != 0.0f &&
		(MipLevel == 0) &&