r.PathTracing.TemporalDenoiser.MotionOperation

r.PathTracing.TemporalDenoiser.MotionOperation

#Overview

name: r.PathTracing.TemporalDenoiser.MotionOperation

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.MotionOperation is to control the motion vector operation in the path tracing temporal denoiser. This setting variable is part of Unreal Engine 5’s path tracing and denoising system, which is a crucial component of the rendering pipeline.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the path tracing and temporal denoising subsystem. It’s referenced in the file PathTracingSpatialTemporalDenoising.cpp, indicating its relevance to the spatial-temporal denoising process for path-traced rendering.

The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It’s initialized with a default value of 1 in the C++ code.

The associated variable CVarPathTracingTemporalDenoiserMotionOperation directly interacts with r.PathTracing.TemporalDenoiser.MotionOperation. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects how motion vectors are processed in the temporal denoiser:

This choice can significantly impact the quality and performance of the denoising process, especially in scenes with complex motion.

Best practices when using this variable include:

  1. Testing both options (0 and 1) to determine which produces better results for your specific scene and motion characteristics.
  2. Consider the performance implications of each option, as subtracting motion between frames (1) may be more computationally expensive but could provide better quality in some scenarios.
  3. Use in conjunction with other temporal denoising settings for optimal results.

Regarding the associated variable CVarPathTracingTemporalDenoiserMotionOperation:

Its purpose is identical to r.PathTracing.TemporalDenoiser.MotionOperation, serving as the actual CVar implementation in the engine’s code.

It’s used within the Renderer module, specifically in the path tracing and temporal denoising subsystem.

The value is set through the CVar system and can be modified at runtime.

It interacts directly with other temporal denoising CVars, such as CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip and CVarPathTracingTemporalDenoiserEnableSubPixelOffset, as seen in the ShouldRemoveSelfSubpixelOffset function.

Developers should be aware that this variable is used in conditional logic that determines whether to remove self-subpixel offset, which can affect the precision of motion handling in the denoiser.

Best practices include:

  1. Understanding the interplay between this variable and other subpixel offset settings.
  2. Profiling the performance impact of different configurations.
  3. Considering the visual quality trade-offs when adjusting these settings in combination.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMotionOperation(
	   TEXT("r.PathTracing.TemporalDenoiser.MotionOperation"),
		1,
		TEXT("0: use the motion vector directly estimated")
		TEXT("1: subtract between the motion"),
		ECVF_RenderThreadSafe
	);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMotionOperation(
	   TEXT("r.PathTracing.TemporalDenoiser.MotionOperation"),
		1,
		TEXT("0: use the motion vector directly estimated")
		TEXT("1: subtract between the motion"),
		ECVF_RenderThreadSafe
	);

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

Scope (from outer to inner):

file
function     static bool ShouldRemoveSelfSubpixelOffset

Source code excerpt:

static bool ShouldRemoveSelfSubpixelOffset(int MipLevel)
{
	bool bRemoveSelfSubpixelOffset = CVarPathTracingTemporalDenoiserMotionOperation.GetValueOnRenderThread() == 1 
		&& MipLevel <= CVarPathTracingTemporalDenoiserSubPixelOffsetStartMip.GetValueOnRenderThread()
		&& CVarPathTracingTemporalDenoiserEnableSubPixelOffset.GetValueOnAnyThread() != 0;

	return bRemoveSelfSubpixelOffset;
}