r.TSR.ShadingRejection.SampleCount
r.TSR.ShadingRejection.SampleCount
#Overview
name: r.TSR.ShadingRejection.SampleCount
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of sample in each output pixel of the history after total shading rejection.\n\nLower values means higher clarity of the image after shading rejection of the history, but at the trade of higher instability of the pixel on following frames accumulating new details which can be distracting to the human eye (Defaults to 2.0).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.TSR.ShadingRejection.SampleCount is to control the maximum number of samples in each output pixel of the history after total shading rejection in Unreal Engine’s Temporal Super Resolution (TSR) system. This setting is part of the rendering system, specifically the post-processing pipeline.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly within the Temporal Super Resolution implementation. It’s referenced in the TemporalSuperResolution.cpp file, which is part of the post-processing pipeline.
The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s initialized with a default value of 2.0f.
The associated variable CVarTSRHistoryRejectionSampleCount directly interacts with r.TSR.ShadingRejection.SampleCount, as they share the same value and purpose.
Developers must be aware that this variable affects the trade-off between image clarity and stability in the TSR process. Lower values result in higher clarity after shading rejection but can lead to increased instability in pixels accumulating new details in subsequent frames, which may be distracting to viewers.
Best practices when using this variable include:
- Carefully consider the balance between clarity and stability for your specific use case.
- Test different values to find the optimal setting for your game’s visual style and performance requirements.
- Be mindful of potential visual artifacts or flickering that may occur with very low values.
- Consider exposing this setting to end-users for fine-tuning, especially in PC games where hardware capabilities can vary significantly.
Regarding the associated variable CVarTSRHistoryRejectionSampleCount:
The purpose of CVarTSRHistoryRejectionSampleCount is identical to r.TSR.ShadingRejection.SampleCount, as it’s the internal representation of the console variable.
This variable is used in the Renderer module, specifically in the TemporalSuperResolution.cpp file. It’s part of the implementation of the Temporal Super Resolution feature.
The value of CVarTSRHistoryRejectionSampleCount is set when the console variable r.TSR.ShadingRejection.SampleCount is initialized or changed.
It interacts directly with other TSR-related variables and parameters, such as HistorySampleCount, HistoryHisteresis, and WeightClampingRejection.
Developers should be aware that this variable is used in calculations for weight clamping and rejection in the TSR process. Changes to this value will directly affect the behavior of the temporal upscaling.
Best practices for using CVarTSRHistoryRejectionSampleCount include:
- Access its value using GetValueOnRenderThread() when needed in render thread operations.
- Consider the impact on other related parameters when modifying this value.
- Use in conjunction with other TSR settings for optimal results.
- Profile and test thoroughly when adjusting this value to ensure desired visual quality and performance.
#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:107
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<float> CVarTSRHistoryRejectionSampleCount(
TEXT("r.TSR.ShadingRejection.SampleCount"), 2.0f,
TEXT("Maximum number of sample in each output pixel of the history after total shading rejection.\n")
TEXT("\n")
TEXT("Lower values means higher clarity of the image after shading rejection of the history, but at the trade of higher instability ")
TEXT("of the pixel on following frames accumulating new details which can be distracting to the human eye (Defaults to 2.0)."),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarTSRHistoryRejectionSampleCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:106
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
#endif // PLATFORM_DESKTOP
TAutoConsoleVariable<float> CVarTSRHistoryRejectionSampleCount(
TEXT("r.TSR.ShadingRejection.SampleCount"), 2.0f,
TEXT("Maximum number of sample in each output pixel of the history after total shading rejection.\n")
TEXT("\n")
TEXT("Lower values means higher clarity of the image after shading rejection of the history, but at the trade of higher instability ")
TEXT("of the pixel on following frames accumulating new details which can be distracting to the human eye (Defaults to 2.0)."),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:2279
Scope (from outer to inner):
file
function FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses
Source code excerpt:
PassParameters->HistorySampleCount = MaxHistorySampleCount / OutputToHistoryResolutionFractionSquare;
PassParameters->HistoryHisteresis = 1.0f / PassParameters->HistorySampleCount;
PassParameters->WeightClampingRejection = 1.0f - (CVarTSRHistoryRejectionSampleCount.GetValueOnRenderThread() / OutputToHistoryResolutionFractionSquare) * PassParameters->HistoryHisteresis;
PassParameters->WeightClampingPixelSpeedAmplitude = FMath::Clamp(1.0f - CVarTSRWeightClampingSampleCount.GetValueOnRenderThread() * PassParameters->HistoryHisteresis, 0.0f, 1.0f);
PassParameters->InvWeightClampingPixelSpeed = 1.0f / (CVarTSRWeightClampingPixelSpeed.GetValueOnRenderThread() * OutputToHistoryResolutionFraction);
PassParameters->InputToHistoryFactor = float(HistorySize.X) / float(InputRect.Width());
PassParameters->InputContributionMultiplier = OutputToHistoryResolutionFractionSquare;
PassParameters->bGenerateOutputMip1 = false;