r.TSR.Visualize
r.TSR.Visualize
#Overview
name: r.TSR.Visualize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Selects the TSR internal visualization mode.\n -2: Display an overview grid based regardless of VisualizeTSR show flag;\n -1: Display an overview grid based on the VisualizeTSR show flag (default, opened with the
show VisualizeTSRcommand at runtime or Show > Visualize > TSR in editor viewports);\n 0: Number of accumulated samples in the history, particularily interesting to tune r.TSR.ShadingRejection.SampleCount and r.TSR.Velocity.WeightClampingSampleCount;\n 1: Parallax disocclusion based of depth and velocity buffers;\n 2: Mask where the history is rejected;\n 3: Mask where the history is clamped;\n 4: Mask where the history is resurrected (with r.TSR.Resurrection=1);\n 5: Mask where the history is resurrected in the resurrected frame (with r.TSR.Resurrection=1), particularily interesting to tune r.TSR.Resurrection.PersistentFrameInterval;\n 6: Mask where spatial anti-aliasing is being computed;\n 7: Mask where the flickering temporal analysis heuristic is taking effects (with r.TSR.ShadingRejection.Flickering=1);\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.TSR.Visualize is to control the visualization mode for Temporal Super Resolution (TSR) in Unreal Engine 5. This setting variable is primarily used for debugging and fine-tuning the TSR system, which is part of the rendering subsystem.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the Temporal Super Resolution component. This can be seen from the file path where the variable is defined: “Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp”.
The value of this variable is set through the console variable system in Unreal Engine. It can be changed at runtime using console commands or through configuration files.
This variable interacts closely with the VisualizeTSR show flag, as seen in the code where it checks for both the CVarTSRVisualize value and the VisualizeTSR show flag.
Developers must be aware that this variable has different behaviors based on the build configuration. In non-optimized builds (debug or development), it offers more visualization options, while in optimized builds, some options might be limited.
Best practices when using this variable include:
- Use it primarily for debugging and development purposes, not in production builds.
- Understand the different visualization modes and what they represent to effectively debug TSR issues.
- Be aware of the performance impact when enabling these visualizations, especially in complex scenes.
The associated variable CVarTSRVisualize is actually the console variable that directly controls the r.TSR.Visualize setting. It’s defined using TAutoConsoleVariable
- -2: Always display an overview grid
- -1: Display an overview grid based on the VisualizeTSR show flag (default)
- 0: Visualize the number of accumulated samples in history
- 1: Visualize parallax disocclusion based on depth and velocity buffers
- 2: Visualize the mask where history is rejected
Developers should use these visualization modes to diagnose issues with TSR, such as ghosting, flickering, or other artifacts. The different modes can help identify problems with sample accumulation, disocclusion handling, and history rejection, which are crucial aspects of the TSR algorithm.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:292
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<int32> CVarTSRVisualize(
TEXT("r.TSR.Visualize"), -1,
TEXT("Selects the TSR internal visualization mode.\n")
TEXT(" -2: Display an overview grid based regardless of VisualizeTSR show flag;\n")
TEXT(" -1: Display an overview grid based on the VisualizeTSR show flag (default, opened with the `show VisualizeTSR` command at runtime or Show > Visualize > TSR in editor viewports);\n")
TEXT(" 0: Number of accumulated samples in the history, particularily interesting to tune r.TSR.ShadingRejection.SampleCount and r.TSR.Velocity.WeightClampingSampleCount;\n")
TEXT(" 1: Parallax disocclusion based of depth and velocity buffers;\n")
TEXT(" 2: Mask where the history is rejected;\n")
#Associated Variable and Callsites
This variable is associated with another variable named CVarTSRVisualize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:291
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
#if !UE_BUILD_OPTIMIZED_SHOWFLAGS
TAutoConsoleVariable<int32> CVarTSRVisualize(
TEXT("r.TSR.Visualize"), -1,
TEXT("Selects the TSR internal visualization mode.\n")
TEXT(" -2: Display an overview grid based regardless of VisualizeTSR show flag;\n")
TEXT(" -1: Display an overview grid based on the VisualizeTSR show flag (default, opened with the `show VisualizeTSR` command at runtime or Show > Visualize > TSR in editor viewports);\n")
TEXT(" 0: Number of accumulated samples in the history, particularily interesting to tune r.TSR.ShadingRejection.SampleCount and r.TSR.Velocity.WeightClampingSampleCount;\n")
TEXT(" 1: Parallax disocclusion based of depth and velocity buffers;\n")
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:1209
Scope: file
Source code excerpt:
#else
{
int32 VisualizeSettings = CVarTSRVisualize.GetValueOnRenderThread();
return GetMainTAAPassConfig(View) == EMainTAAPassConfig::TSR && (View.Family->EngineShowFlags.VisualizeTSR || VisualizeSettings != -1);
}
#endif
FScreenPassTexture AddTSRMeasureFlickeringLuma(FRDGBuilder& GraphBuilder, FGlobalShaderMap* ShaderMap, FScreenPassTexture SceneColor)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:2597
Scope (from outer to inner):
file
function FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses
Source code excerpt:
static_assert(UE_ARRAY_COUNT(kVisualizationName) == int32(EVisualizeId::MAX), "kVisualizationName doesn't match EVisualizeId");
const EVisualizeId Visualization = EVisualizeId(FMath::Clamp(CVarTSRVisualize.GetValueOnRenderThread(), int32(EVisualizeId::Overview), int32(EVisualizeId::MAX) - 1));
FIntRect VisualizeRect = Visualization == EVisualizeId::Overview ? FIntRect(OutputRect.Min + OutputRect.Size() / 4, OutputRect.Min + (OutputRect.Size() * 3) / 4) : OutputRect;
auto Visualize = [&](EVisualizeId VisualizeId, FString Label)
{
check(VisualizeId != EVisualizeId::Overview);