r.PathTracing.TemporalDenoiser.VisualizeMotionVector

r.PathTracing.TemporalDenoiser.VisualizeMotionVector

#Overview

name: r.PathTracing.TemporalDenoiser.VisualizeMotionVector

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.VisualizeMotionVector is to enable visualization of motion vectors in the path tracing temporal denoiser. This setting is primarily used for debugging and analysis of the path tracing rendering system.

This setting variable is utilized by the Unreal Engine’s rendering subsystem, specifically within the path tracing and denoising modules. It is defined and used in the PathTracingSpatialTemporalDenoising.cpp file, which is part of the Renderer module.

The value of this variable is set through the Unreal Engine’s console variable system. It is initialized with a default value of 0 and can be changed at runtime using console commands.

The associated variable CVarPathTracingTemporalDenoiserVisualizeMotionVector directly interacts with this setting. It is used to retrieve the current value of the setting in the rendering thread.

Developers should be aware that enabling this visualization (by setting the value to 1) will affect the visual output of the path tracing system. It’s intended for debugging purposes and should not be enabled in production builds or during normal gameplay.

Best practices when using this variable include:

  1. Use it only during development and debugging phases.
  2. Disable it (set to 0) before building final releases.
  3. Be cautious when enabling it in performance-sensitive scenarios, as it may impact rendering performance.

Regarding the associated variable CVarPathTracingTemporalDenoiserVisualizeMotionVector:

This is an internal console variable that directly corresponds to the r.PathTracing.TemporalDenoiser.VisualizeMotionVector setting. It is used within the rendering code to efficiently access the current value of the setting.

The purpose of this variable is to provide a quick way for the rendering system to check if motion vector visualization should be enabled. It is used in the ShouldVisualizePathTracingVelocityState function to determine whether to visualize the path tracing velocity state.

This variable is part of the rendering subsystem and is specifically used in the path tracing temporal denoising process.

The value of this variable is set automatically by the Unreal Engine console variable system based on the r.PathTracing.TemporalDenoiser.VisualizeMotionVector setting.

Developers should treat this variable as read-only within their code. Changes to the visualization behavior should be made through the r.PathTracing.TemporalDenoiser.VisualizeMotionVector setting rather than directly modifying this variable.

Best practices for using this variable include:

  1. Use GetValueOnRenderThread() when accessing its value, as demonstrated in the provided code.
  2. Do not attempt to modify this variable directly; instead, use the corresponding console command to change the setting.
  3. Be aware of potential performance implications when the visualization is enabled.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserVisualizeMotionVector(
		TEXT("r.PathTracing.TemporalDenoiser.VisualizeMotionVector"),
		0,
		TEXT("1: visualize the motion vector compared to the raster motion vector\n"),
		ECVF_RenderThreadSafe
	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserEnableSubPixelOffset(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserVisualizeMotionVector(
		TEXT("r.PathTracing.TemporalDenoiser.VisualizeMotionVector"),
		0,
		TEXT("1: visualize the motion vector compared to the raster motion vector\n"),
		ECVF_RenderThreadSafe
	);

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

Scope (from outer to inner):

file
function     static bool ShouldVisualizePathTracingVelocityState

Source code excerpt:

static bool ShouldVisualizePathTracingVelocityState(const FPathTracingSpatialTemporalDenoisingContext& DenoisingContext)
{
	bool bVisualizeMotionVector = CVarPathTracingTemporalDenoiserVisualizeMotionVector.GetValueOnRenderThread() != 0;

	return bVisualizeMotionVector && DenoisingContext.MotionVector;
}

static bool ShouldVisualizeWarping(const FPathTracingSpatialTemporalDenoisingContext& DenoisingContext)
{