r.PathTracing.Denoiser.Prepass.VarianceType

r.PathTracing.Denoiser.Prepass.VarianceType

#Overview

name: r.PathTracing.Denoiser.Prepass.VarianceType

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.Denoiser.Prepass.VarianceType is to control the type of per-pixel variance used in the path tracing denoiser prepass. This setting 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 5, as evidenced by its location in the “Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp” file. It is particularly relevant to the path tracing and denoising subsystems within the renderer.

The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It is initialized with a default value of 1, but can be changed during runtime or through configuration files.

The variable interacts directly with its associated variable CVarPathTracingDenoiserPrepassVarianceType, which is used to retrieve the current value of the setting. This value is then used to determine the variance type in the FTemporalPrepassCS class.

Developers should be aware that this variable affects the quality and performance of the path tracing denoiser. The two options (0 and 1) represent different approaches to calculating variance: 0: Uses multiple channel (RGB) variance for radiance 1: Uses a combined single channel variance for radiance, albedo, and normal

Best practices when using this variable include:

  1. Understanding the trade-offs between the two variance types in terms of quality and performance.
  2. Testing both options in various scenarios to determine which works best for your specific use case.
  3. Considering the impact on performance, especially in real-time applications.
  4. Potentially exposing this setting to artists or technical artists for fine-tuning in different environments or scenes.

Regarding the associated variable CVarPathTracingDenoiserPrepassVarianceType:

The purpose of CVarPathTracingDenoiserPrepassVarianceType is to provide a programmatic interface to access and modify the r.PathTracing.Denoiser.Prepass.VarianceType setting.

This variable is used within the Renderer module, specifically in the path tracing and denoising systems. It’s primarily accessed in the FTemporalPrepassCS class to determine the variance type for the temporal prepass computation.

The value of this variable is set automatically by the CVar system based on the r.PathTracing.Denoiser.Prepass.VarianceType setting. It can be accessed using the GetValueOnRenderThread() method.

This variable interacts directly with the EVarianceType enum in the FTemporalPrepassCS class, which defines the possible variance types.

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

Best practices when using this variable include:

  1. Accessing it only on the render thread using GetValueOnRenderThread().
  2. Using the FMath::Clamp function when retrieving the value to ensure it’s within the valid range.
  3. Considering caching the value if it’s accessed frequently, to avoid potential performance overhead from repeated CVar lookups.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingDenoiserPrepassVarianceType(
		TEXT("r.PathTracing.Denoiser.Prepass.VarianceType"),
		1,
		TEXT("Select the per-pixel variance type:")
		TEXT("0: Multiple channel (RGB) variance for radiance")
		TEXT("1: Combined single channel variance for radiance, albedo and normal"),
		ECVF_RenderThreadSafe
	);

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingDenoiserPrepassVarianceType(
		TEXT("r.PathTracing.Denoiser.Prepass.VarianceType"),
		1,
		TEXT("Select the per-pixel variance type:")
		TEXT("0: Multiple channel (RGB) variance for radiance")
		TEXT("1: Combined single channel variance for radiance, albedo and normal"),
		ECVF_RenderThreadSafe

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

Scope (from outer to inner):

file
class        class FTemporalPrepassCS : public FGlobalShader
function     static EVarianceType GetVarianceType

Source code excerpt:

	{
		return static_cast<FTemporalPrepassCS::EVarianceType>(
			FMath::Clamp(CVarPathTracingDenoiserPrepassVarianceType.GetValueOnRenderThread(),
				0,
				static_cast<int32>(EVarianceType::MAX) - 1));
	}

	static const TCHAR* GetEventName(EVarianceType VarianceType)
	{