r.PathTracing.TemporalDenoiser.source
r.PathTracing.TemporalDenoiser.source
#Overview
name: r.PathTracing.TemporalDenoiser.source
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Denoised Radance when possible (Default) \n1: Normal\n2: Albedo\n3: Raw RadianceOtherwise: Feature Fusion (TODO)
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.TemporalDenoiser.source is to control the source input for the temporal denoiser in the path tracing rendering system of Unreal Engine 5. This setting variable is primarily used in the rendering subsystem, specifically for path tracing and denoising.
The rendering module of Unreal Engine 5 relies on this setting variable, as evident from its usage in the “Renderer” source files.
The value of this variable is set through a console variable (CVarPathTracingTemporalDenoiserSource) with a default value of 0. It can be changed at runtime using console commands or through engine configuration files.
This variable interacts with several other components of the path tracing system:
- It determines whether a variance map should be generated (ShouldGenerateVarianceMap function).
- It affects whether pre-exposure should be applied to motion vector estimation (ShouldApplyPreExposureToMotionVectorEstimation function).
- It influences the selection of motion source and target textures for denoising (SelectMotionSourceAndTargetTextures function).
Developers must be aware that this variable significantly impacts the path tracing denoising process. Different values result in different inputs to the denoiser, which can affect the final rendered image quality and performance.
Best practices when using this variable include:
- Use the default value (0) for typical scenarios, as it uses denoised radiance when possible.
- Experiment with other values (1-3) if specific visual artifacts or performance issues are observed.
- Be cautious when using values outside the 0-3 range, as this triggers a “Feature Fusion” mode that may not be fully implemented (as indicated by the “TODO” comment).
Regarding the associated variable CVarPathTracingTemporalDenoiserSource:
The purpose of CVarPathTracingTemporalDenoiserSource is to provide a console-accessible interface for the r.PathTracing.TemporalDenoiser.source setting. It is an implementation detail that allows the engine to expose the setting to users and developers through the console system.
This variable is used directly in the rendering code to retrieve the current value of the setting. It’s typically accessed using the GetValueOnRenderThread() or GetValueOnAnyThread() methods, depending on the context.
When working with this variable, developers should:
- Use the appropriate getter method based on the execution context (render thread vs. other threads).
- Be aware that changes to this variable at runtime will immediately affect the path tracing denoising behavior.
- Consider providing user-friendly ways to modify this setting in-game if real-time adjustment of path tracing quality is desired.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:175
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserSource(
TEXT("r.PathTracing.TemporalDenoiser.source"),
0,
TEXT("0: Denoised Radance when possible (Default) \n")
TEXT("1: Normal\n")
TEXT("2: Albedo\n")
TEXT("3: Raw Radiance")
TEXT("Otherwise: Feature Fusion (TODO)"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingTemporalDenoiserSource
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:174
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingTemporalDenoiserSource(
TEXT("r.PathTracing.TemporalDenoiser.source"),
0,
TEXT("0: Denoised Radance when possible (Default) \n")
TEXT("1: Normal\n")
TEXT("2: Albedo\n")
TEXT("3: Raw Radiance")
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:475
Scope (from outer to inner):
file
function static bool ShouldGenerateVarianceMap
Source code excerpt:
static bool ShouldGenerateVarianceMap()
{
int32 PathTracingTemporalDenoiserSource = CVarPathTracingTemporalDenoiserSource.GetValueOnRenderThread();
return PathTracingTemporalDenoiserSource < 0 || PathTracingTemporalDenoiserSource > 3;
}
static bool ShouldVisualizePathTracingVelocityState(const FPathTracingSpatialTemporalDenoisingContext& DenoisingContext)
{
bool bVisualizeMotionVector = CVarPathTracingTemporalDenoiserVisualizeMotionVector.GetValueOnRenderThread() != 0;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:985
Scope (from outer to inner):
file
function static bool ShouldApplyPreExposureToMotionVectorEstimation
Source code excerpt:
static bool ShouldApplyPreExposureToMotionVectorEstimation()
{
int32 DenoiserSource = CVarPathTracingTemporalDenoiserSource.GetValueOnRenderThread();
if (DenoiserSource == 0 || DenoiserSource == 3)
{
return true;
}
return false;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracingSpatialTemporalDenoising.cpp:1460
Scope (from outer to inner):
file
function static bool SelectMotionSourceAndTargetTextures
Source code excerpt:
FRDGTextureRef& MotionEstimationTargetTexture)
{
int32 MotionSource = CVarPathTracingTemporalDenoiserSource.GetValueOnAnyThread();
switch (MotionSource)
{
case 3:
MotionEstimationSourceTexture = DenoisingContext.LastRadianceTexture;
MotionEstimationTargetTexture = DenoisingContext.RadianceTexture;