r.PathTracing.SpatialDenoiser

r.PathTracing.SpatialDenoiser

#Overview

name: r.PathTracing.SpatialDenoiser

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.SpatialDenoiser is to control the spatial denoising of path-traced output in Unreal Engine’s rendering system. This setting variable is part of the path tracing and denoising functionality within the rendering pipeline.

This setting variable is primarily used by the Renderer module of Unreal Engine, specifically in the path tracing and denoising subsystem. It’s referenced in the PathTracingSpatialTemporalDenoising.cpp file, which suggests it’s crucial for the spatial-temporal denoising process applied to path-traced renders.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning the spatial denoiser is enabled by default if a denoiser plugin is active.

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

Developers must be aware that this variable has three possible values:

The best practices when using this variable include:

  1. Ensure a denoiser plugin is active when enabling this feature.
  2. Consider the performance implications of enabling the spatial denoiser, as it may impact render times.
  3. Use the PostProcessVolume inheritance option (-1) for more fine-grained control in different areas of your scene.
  4. Test the visual quality and performance with the denoiser enabled and disabled to find the optimal setting for your project.

Regarding the associated variable CVarPathTracingSpatialDenoiser:

The purpose of CVarPathTracingSpatialDenoiser is to provide a programmatic way to access and modify the r.PathTracing.SpatialDenoiser setting within the C++ code of the engine.

This variable is used directly in the Renderer module, specifically in the path tracing and denoising subsystem. It’s used to determine whether the spatial denoiser should be applied in the ShouldApplySpatialDenoiser() function.

The value of CVarPathTracingSpatialDenoiser is set through the CVar system, mirroring the r.PathTracing.SpatialDenoiser setting.

CVarPathTracingSpatialDenoiser interacts directly with r.PathTracing.SpatialDenoiser, effectively serving as its in-code representation.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is important for thread safety in rendering code.

Best practices for using CVarPathTracingSpatialDenoiser include:

  1. Always access its value using the GetValueOnRenderThread() method when in render thread code.
  2. Be cautious about changing its value during runtime, as it may affect ongoing rendering processes.
  3. Consider using this variable for conditional logic in rendering code that depends on the spatial denoiser state.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingSpatialDenoiser(
		TEXT("r.PathTracing.SpatialDenoiser"),
		1,
		TEXT("Enable spatial denoising of the path traced output\n")
		TEXT("-1: inherit from PostProcessVolume\n")
		TEXT("0: disable denoiser\n")
		TEXT("1: enable denoiser (if a denoiser plugin is active)\n"),
		ECVF_RenderThreadSafe

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingSpatialDenoiser(
		TEXT("r.PathTracing.SpatialDenoiser"),
		1,
		TEXT("Enable spatial denoising of the path traced output\n")
		TEXT("-1: inherit from PostProcessVolume\n")
		TEXT("0: disable denoiser\n")
		TEXT("1: enable denoiser (if a denoiser plugin is active)\n"),

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

Scope (from outer to inner):

file
function     static bool ShouldApplySpatialDenoiser

Source code excerpt:

static bool ShouldApplySpatialDenoiser()
{
	return CVarPathTracingSpatialDenoiser.GetValueOnRenderThread() != 0;
}


TArray<ESpatialDenoiserType> GetAvailableSpatialDenoiserTypes()
{
	TArray<ESpatialDenoiserType> Types;