r.PathTracing.TemporalDenoiser.MotionVector.Type

r.PathTracing.TemporalDenoiser.MotionVector.Type

#Overview

name: r.PathTracing.TemporalDenoiser.MotionVector.Type

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.MotionVector.Type is to control the type of motion vector estimation algorithm used in the path tracing temporal denoiser. This setting variable is part of Unreal Engine 5’s rendering system, specifically for the path tracing and denoising functionality.

This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the ‘Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp’ file. It’s specifically related to the path tracing and temporal denoising subsystems within the renderer.

The value of this variable is set through a console variable (CVarPathTracingTemporalDenoiserMotionVectorType) using the TAutoConsoleVariable template. It’s initialized with a default value of 0, which corresponds to the built-in motion vector estimator.

The associated variable CVarPathTracingTemporalDenoiserMotionVectorType directly interacts with this setting. It’s used to retrieve the current value of the setting and convert it to the appropriate enum type (ETemporalDenoiserMotionVectorType) in the GetTemporalDenoiserMotionVectorType() function.

Developers must be aware that this variable accepts two values: 0: Built-in motion vector estimator 1: Motion vector estimator from the plugin

It’s important to note that the value is clamped between the minimum and maximum enum values of ETemporalDenoiserMotionVectorType, excluding the NONE and MAX values.

Best practices when using this variable include:

  1. Only modify it if you have a specific reason to change the motion vector estimation algorithm.
  2. Be aware of the performance implications of switching between the built-in estimator and the plugin estimator.
  3. If developing a custom plugin for motion vector estimation, ensure it’s compatible with the path tracing temporal denoiser system.

Regarding the associated variable CVarPathTracingTemporalDenoiserMotionVectorType: Its purpose is to provide a programmatic interface to get and set the motion vector estimation algorithm type. It’s used within the renderer to determine which motion vector estimation method to use during the temporal denoising process in path tracing.

This variable is defined and used in the same Renderer module, specifically in the path tracing and temporal denoising subsystem. Its value is set when the r.PathTracing.TemporalDenoiser.MotionVector.Type console variable is modified.

The GetTemporalDenoiserMotionVectorType() function uses this variable to retrieve the current setting and convert it to the appropriate enum type for use in the rendering code.

Developers should be aware that modifying this variable directly may not have the intended effect, as it’s designed to be controlled through the console variable system. Always use the appropriate console commands or project settings to modify this value.

Best practices include using the GetValueOnRenderThread() method to access its value, as shown in the GetTemporalDenoiserMotionVectorType() function, to ensure thread-safe access in rendering code.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMotionVectorType(
		TEXT("r.PathTracing.TemporalDenoiser.MotionVector.Type"),
		0,
		TEXT("The type of motion vecotr estimation algorithm\n")
		TEXT("0: Built-in motion vector estimator\n")
		TEXT("1: Motion vector estimator from the plugin\n"),
		ECVF_RenderThreadSafe
	);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMotionVectorType(
		TEXT("r.PathTracing.TemporalDenoiser.MotionVector.Type"),
		0,
		TEXT("The type of motion vecotr estimation algorithm\n")
		TEXT("0: Built-in motion vector estimator\n")
		TEXT("1: Motion vector estimator from the plugin\n"),
		ECVF_RenderThreadSafe

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

Scope (from outer to inner):

file
function     ETemporalDenoiserMotionVectorType GetTemporalDenoiserMotionVectorType

Source code excerpt:

ETemporalDenoiserMotionVectorType GetTemporalDenoiserMotionVectorType()
{
	int32 Type = CVarPathTracingTemporalDenoiserMotionVectorType.GetValueOnRenderThread();

	Type = FMath::Clamp(Type,
		static_cast<int32>(ETemporalDenoiserMotionVectorType::NONE) + 1,
		static_cast<int32>(ETemporalDenoiserMotionVectorType::MAX) - 1);

	return static_cast<ETemporalDenoiserMotionVectorType>(Type);