r.PathTracing.TemporalDenoiser.TotalVariation

r.PathTracing.TemporalDenoiser.TotalVariation

#Overview

name: r.PathTracing.TemporalDenoiser.TotalVariation

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.TotalVariation is to control the temporal denoising process in the path tracing system of Unreal Engine 5. Specifically, it determines whether to use less history data if the total variation is large in a local patch during the denoising process.

This setting variable is primarily used by the rendering subsystem, particularly in the path tracing and denoising modules. Based on the callsites, it’s implemented in the PathTracingSpatialTemporalDenoising.cpp file, which is part of the Renderer module.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 1, meaning the feature is enabled by default.

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

Developers should be aware that this variable affects the quality and performance of the path tracing denoising process. When enabled (!=0), it can potentially improve the visual quality of the rendered image by reducing artifacts in areas with high variation, but it may also increase computational cost.

Best practices for using this variable include:

  1. Testing the visual impact and performance with and without this feature enabled.
  2. Considering disabling it if performance is a higher priority than visual quality in areas with high variation.
  3. Using it in conjunction with other path tracing and denoising settings for optimal results.

Regarding the associated variable CVarPathTracingTemporalDenoiserTotalVariation:

This is a TAutoConsoleVariable that directly corresponds to the r.PathTracing.TemporalDenoiser.TotalVariation setting. It’s used to access the setting’s value within the C++ code.

The purpose of this variable is to provide a programmatic way to check the state of the total variation feature in the temporal denoiser.

It’s primarily used in the rendering subsystem, specifically in the path tracing and denoising modules.

The value of this variable is set automatically based on the r.PathTracing.TemporalDenoiser.TotalVariation console variable.

It interacts with other variables in the ShouldUseTotalVariation function, such as CVarPathTracingTemporalDenoiserEnableSubPixelOffset.

Developers should be aware that this variable is accessed on the render thread, so any modifications should be thread-safe.

Best practices include using GetValueOnRenderThread() when accessing this variable to ensure thread safety, and considering its interaction with other related variables when making rendering decisions.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserTotalVariation(
		TEXT("r.PathTracing.TemporalDenoiser.TotalVariation"),
		1,
		TEXT("!=0: Use less history if the total variation is large in a local patch"),
		ECVF_RenderThreadSafe
	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserPatchCount(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserTotalVariation(
		TEXT("r.PathTracing.TemporalDenoiser.TotalVariation"),
		1,
		TEXT("!=0: Use less history if the total variation is large in a local patch"),
		ECVF_RenderThreadSafe
	);

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

Scope (from outer to inner):

file
function     static bool ShouldUseTotalVariation

Source code excerpt:

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

static bool ShouldEnableSubpixelOffset(uint32 MipLevel)
{