r.PathTracing.Denoiser.Prepass.OutputVarianceTexture

r.PathTracing.Denoiser.Prepass.OutputVarianceTexture

#Overview

name: r.PathTracing.Denoiser.Prepass.OutputVarianceTexture

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.OutputVarianceTexture is to control the output of the variance texture in the path tracing denoiser prepass. This setting is part of the rendering system, specifically related to path tracing and denoising in Unreal Engine 5.

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

The value of this variable is set using a TAutoConsoleVariable, which means it can be changed at runtime through console commands. By default, it’s set to 1.

This variable interacts with other path tracing and denoising-related variables, as evidenced by its use in the ShouldPrepassOutputVarianceTexture function. It works in conjunction with CVarOutputPostProcessResources and is checked against the IsPathTracingVarianceTextureRequiredInPostProcessMaterial function.

Developers should be aware that this variable has two states: 0: The variance is used only in the denoiser 1: The variance is output to the postprocess material, usually used by MRQ (Multi-Resolution Querying)

Best practices when using this variable include:

  1. Consider the performance implications of outputting the variance texture to the postprocess material.
  2. Use it in conjunction with other path tracing and denoising settings for optimal results.
  3. Be aware of its impact on the MRQ system if enabled.

Regarding the associated variable CVarPathTracingDenoiserPrepassOutputVarianceTexture:

This is the actual TAutoConsoleVariable instance that controls the behavior described above. It’s used internally by the engine to store and retrieve the current value of the r.PathTracing.Denoiser.Prepass.OutputVarianceTexture setting.

The purpose of CVarPathTracingDenoiserPrepassOutputVarianceTexture is to provide a programmatic interface for the r.PathTracing.Denoiser.Prepass.OutputVarianceTexture setting within the C++ code of the engine.

This variable is used in the Renderer module, specifically in the path tracing and denoising subsystem. It’s directly accessed in the ShouldPrepassOutputVarianceTexture function to determine whether the variance texture should be output.

The value of this variable is set when the TAutoConsoleVariable is initialized, but can be changed at runtime through console commands.

Developers should be aware that this is the actual variable that stores the state of the setting. When writing C++ code that needs to check this setting, they should use CVarPathTracingDenoiserPrepassOutputVarianceTexture.GetValueOnRenderThread() to get the current value.

Best practices for using this variable include:

  1. Always access its value using GetValueOnRenderThread() when in render thread code.
  2. Be aware of potential performance implications when changing this value, especially in performance-critical sections of code.
  3. Consider caching the value if it’s accessed frequently in a single frame, to avoid repeated calls to GetValueOnRenderThread().

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarPathTracingDenoiserPrepassOutputVarianceTexture(
		TEXT("r.PathTracing.Denoiser.Prepass.OutputVarianceTexture"),
		1,
		TEXT("0: Variance is used only in the denoiser")
		TEXT("1: Output to the postprocess material, usually used by MRQ")
	);

	TAutoConsoleVariable<int32> CVarPathTracingSpatialDenoiser(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	);

	TAutoConsoleVariable<int32> CVarPathTracingDenoiserPrepassOutputVarianceTexture(
		TEXT("r.PathTracing.Denoiser.Prepass.OutputVarianceTexture"),
		1,
		TEXT("0: Variance is used only in the denoiser")
		TEXT("1: Output to the postprocess material, usually used by MRQ")
	);

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

Scope (from outer to inner):

file
function     static bool ShouldPrepassOutputVarianceTexture

Source code excerpt:

		(CVarOutputPostProcessResources->GetValueOnRenderThread() != 0) : false;

	return CVarPathTracingDenoiserPrepassOutputVarianceTexture.GetValueOnRenderThread() != 0 &&
		bOutputPostProcessResources && 
		IsPathTracingVarianceTextureRequiredInPostProcessMaterial(View);
}

static constexpr uint32 kMipDiffDelta = 2;