r.TSR.History.ScreenPercentage

r.TSR.History.ScreenPercentage

#Overview

name: r.TSR.History.ScreenPercentage

The value of this variable can be defined or overridden in .ini config files. 5 .ini config files referencing this setting variable.

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.TSR.History.ScreenPercentage is to control the resolution multiplier of the history buffer used in Temporal Super Resolution (TSR) based on the output resolution. This setting variable is part of Unreal Engine 5’s rendering system, specifically the Temporal Super Resolution feature.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the Temporal Super Resolution component within the post-processing pipeline.

The value of this variable is set through the console variable system, with a default value of 100.0f. It can be adjusted at runtime or through configuration files.

This variable interacts closely with its associated variable CVarTSRHistorySP, which is the actual TAutoConsoleVariable instance used to store and retrieve the value.

Developers must be aware of several important aspects when using this variable:

  1. The value represents a percentage, with 100 being the default (no upscaling).
  2. Only values between 100 and 200 are supported.
  3. Increasing the value improves sharpness and stability of details in the history buffer but adds runtime cost to TSR.
  4. Setting it to 200 has a special property related to the Nyquist-Shannon sampling theorem, providing optimal sampling for accumulated details.

Best practices when using this variable include:

  1. Use the anti-aliasing scalability group to control this setting, which sets it to 200 on Epic and Cinematic quality levels, and 100 otherwise.
  2. Be mindful of the performance impact when increasing the value above 100.
  3. Consider the target hardware capabilities when adjusting this setting.
  4. Test thoroughly to find the optimal balance between image quality and performance for your specific use case.

Regarding the associated variable CVarTSRHistorySP:

This is the actual TAutoConsoleVariable instance that stores and provides access to the r.TSR.History.ScreenPercentage value. It is used internally by the Temporal Super Resolution system to retrieve the current setting value during rendering. The variable is defined in the Renderer module and is accessed on the render thread for performance reasons.

When working with CVarTSRHistorySP, developers should:

  1. Use GetValueOnRenderThread() to retrieve the current value safely within render thread operations.
  2. Be aware that changes to this variable will affect the TSR history buffer resolution in real-time.
  3. Respect the valid range of 100-200 when programmatically modifying the value.
  4. Consider exposing this setting through user interfaces for advanced graphics options, allowing users to fine-tune TSR performance and quality.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:56, section: [AntiAliasingQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:66, section: [AntiAliasingQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:76, section: [AntiAliasingQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:86, section: [AntiAliasingQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:96, section: [AntiAliasingQuality@Cine]

#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:38

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTSRHistorySP(
	TEXT("r.TSR.History.ScreenPercentage"), 100.0f,
	TEXT("Resolution multiplier of the history of TSR based of output resolution. While increasing the resolution adds runtime cost ")
	TEXT("to TSR, it allows to maintain a better sharpness and stability of the details stored in history through out the reprojection.\n")
	TEXT("\n")
	TEXT("Setting to 200 brings on a very particular property relying on NyQuist-Shannon sampling theorem that establishes a sufficient ")
	TEXT("condition for the sample rate of the accumulated details in the history. As a result only values between 100 and 200 are supported.\n")
	TEXT("It is controlled by default in the anti-aliasing scalability group set to 200 on Epic and Cinematic, 100 otherwise."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:37

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRHistorySP(
	TEXT("r.TSR.History.ScreenPercentage"), 100.0f,
	TEXT("Resolution multiplier of the history of TSR based of output resolution. While increasing the resolution adds runtime cost ")
	TEXT("to TSR, it allows to maintain a better sharpness and stability of the details stored in history through out the reprojection.\n")
	TEXT("\n")
	TEXT("Setting to 200 brings on a very particular property relying on NyQuist-Shannon sampling theorem that establishes a sufficient ")
	TEXT("condition for the sample rate of the accumulated details in the history. As a result only values between 100 and 200 are supported.\n")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalSuperResolution.cpp:1405

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:

		float MaxHistoryUpscaleFactor = FMath::Max(float(GMaxTextureDimensions) / float(FMath::Max(OutputRect.Width(), OutputRect.Height())), 1.0f);

		float HistoryUpscaleFactor = FMath::Clamp(CVarTSRHistorySP.GetValueOnRenderThread() / 100.0f, 1.0f, 2.0f);
		if (HistoryUpscaleFactor > MaxHistoryUpscaleFactor)
		{
			HistoryUpscaleFactor = 1.0f;
		}
		
		HistorySize = FIntPoint(