r.PathTracing.TemporalDenoiser.mode
r.PathTracing.TemporalDenoiser.mode
#Overview
name: r.PathTracing.TemporalDenoiser.mode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: disabled \n1: offline rendering only\n2: online rendering (for debug)\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.TemporalDenoiser.mode is to control the temporal denoising mode for path tracing in Unreal Engine 5. It is primarily used in the rendering system, specifically for path tracing and denoising operations.
This setting variable is relied upon by the Renderer module of Unreal Engine 5, particularly in the path tracing and scene visibility subsystems.
The value of this variable is set through a console variable (CVar) system. It is defined in the PathTracingSpatialTemporalDenoising.cpp file with a default value of 1.
The variable interacts with an associated variable named CVarPathTracingTemporalDenoiserMode. They share the same value and are used interchangeably in different parts of the code.
Developers must be aware that this variable has three possible settings: 0: Temporal denoiser is disabled 1: Temporal denoiser is enabled for offline rendering only 2: Temporal denoiser is enabled for online rendering (debug mode)
Best practices when using this variable include:
- Use the default value (1) for most production scenarios, as it enables temporal denoising for offline rendering.
- Only use mode 2 (online rendering) for debugging purposes, as it may impact performance.
- Be cautious when disabling the temporal denoiser (mode 0), as it may result in noisier path-traced images.
Regarding the associated variable CVarPathTracingTemporalDenoiserMode:
- It serves the same purpose as r.PathTracing.TemporalDenoiser.mode.
- It is used directly in the ShouldEnablePathTracingDenoiserRealtimeDebug function to determine if real-time debug for the path tracing denoiser should be enabled.
- The value is accessed using GetValueOnRenderThread(), ensuring thread-safe access in the rendering context.
- It’s important to note that the value is clamped between 0 and the maximum enum value of ETemporalDenoisingMode to prevent out-of-range issues.
When working with either variable, developers should consider the impact on rendering performance and image quality, especially when switching between offline and online (debug) modes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:166
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMode(
TEXT("r.PathTracing.TemporalDenoiser.mode"),
1,
TEXT("0: disabled \n")
TEXT("1: offline rendering only\n")
TEXT("2: online rendering (for debug)\n"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:5027
Scope (from outer to inner):
file
function void FSceneRenderer::PrepareViewStateForVisibility
Source code excerpt:
#if RHI_RAYTRACING
static const auto CVarTemporalDenoiser = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PathTracing.TemporalDenoiser.mode"));
const int TemporalDenoiserMode = CVarTemporalDenoiser ? CVarTemporalDenoiser->GetValueOnAnyThread() : 0;
if (View.bIsOfflineRender)
{
// In the offline context, we want precise control over when to restart the path tracer's accumulation to allow for motion blur
// So we use the camera cut signal only. In particular - we should not use bForceCameraVisibilityReset since this has
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingTemporalDenoiserMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:165
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserMode(
TEXT("r.PathTracing.TemporalDenoiser.mode"),
1,
TEXT("0: disabled \n")
TEXT("1: offline rendering only\n")
TEXT("2: online rendering (for debug)\n"),
ECVF_RenderThreadSafe
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:299
Scope (from outer to inner):
file
function bool ShouldEnablePathTracingDenoiserRealtimeDebug
Source code excerpt:
bool ShouldEnablePathTracingDenoiserRealtimeDebug()
{
int TemporalDenoiserMode = CVarPathTracingTemporalDenoiserMode.GetValueOnRenderThread();
TemporalDenoiserMode = FMath::Clamp(TemporalDenoiserMode, 0, static_cast<int32>(ETemporalDenoisingMode::ETDM_MAX));
ETemporalDenoisingMode Mode = static_cast<ETemporalDenoisingMode>(TemporalDenoiserMode);
return Mode == ETemporalDenoisingMode::ETDM_ONLINE;
}