r.TSR.ShadingRejection.Flickering.Period

r.TSR.ShadingRejection.Flickering.Period

#Overview

name: r.TSR.ShadingRejection.Flickering.Period

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.TSR.ShadingRejection.Flickering.Period is to control the temporal stability of the image in Unreal Engine’s Temporal Super Resolution (TSR) system. Specifically, it sets the period (in frames) at which luma oscillations are considered flickering and should be ghosted to stabilize the image.

This setting variable is primarily used by the rendering system, particularly within the Temporal Super Resolution subsystem. Based on the callsites, it’s clear that the variable is utilized in the PostProcess module of the Renderer, specifically in the TemporalSuperResolution.cpp file.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 2.0 frames, but can be changed at runtime through console commands or programmatically.

The associated variable CVarTSRFlickeringPeriod interacts directly with r.TSR.ShadingRejection.Flickering.Period. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the visual quality and stability of the rendered image, particularly in scenes with rapidly changing lighting or materials. Adjusting this value can help reduce flickering artifacts, but may also introduce ghosting if set too high.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance between flickering reduction and ghosting for your specific scene.
  2. Consider the target frame rate of your application, as the effectiveness of this setting may vary at different frame rates.
  3. Use in conjunction with other TSR settings for best results.

Regarding the associated variable CVarTSRFlickeringPeriod:

The purpose of CVarTSRFlickeringPeriod is to provide a programmatic interface to the r.TSR.ShadingRejection.Flickering.Period setting. It’s used internally by the engine to access and modify the value of the setting.

This variable is used in the same subsystems as r.TSR.ShadingRejection.Flickering.Period, primarily in the rendering and post-processing modules.

The value of CVarTSRFlickeringPeriod is set when the r.TSR.ShadingRejection.Flickering.Period console variable is initialized or changed.

CVarTSRFlickeringPeriod interacts directly with r.TSR.ShadingRejection.Flickering.Period, and is also used in calculations involving the refresh rate and frame rate cap.

Developers should be aware that changes to CVarTSRFlickeringPeriod will affect the TSR system’s behavior in the same way as changes to r.TSR.ShadingRejection.Flickering.Period.

Best practices for using CVarTSRFlickeringPeriod include:

  1. Use it when you need to programmatically access or modify the flickering period in your C++ code.
  2. Be cautious when modifying this value at runtime, as it can have immediate effects on visual quality.
  3. Consider exposing this setting in your game’s graphics options menu to allow users to fine-tune their visual experience.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTSRFlickeringPeriod(
	TEXT("r.TSR.ShadingRejection.Flickering.Period"), 2.0f,
	TEXT("Periode in frames in which luma oscilations at equal or greater frequency is considered flickering and should ghost to stabilize the image ")
	TEXT("Please read r.TSR.ShadingRejection.Flickering's help for further details. (Default to 3 frames)."),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRFlickeringMaxParralaxVelocity(
	TEXT("r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity"), 10.0,

#Loc: <Workspace>/Engine/Plugins/Experimental/ClonerEffector/Source/ClonerEffector/Private/Subsystems/CEClonerSubsystem.cpp:54

Scope (from outer to inner):

file
function     void UCEClonerSubsystem::Initialize

Source code excerpt:


#if WITH_EDITOR
	CVarTSRShadingRejectionFlickeringPeriod = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TSR.ShadingRejection.Flickering.Period"));

	if (CVarTSRShadingRejectionFlickeringPeriod)
	{
		CVarTSRShadingRejectionFlickeringPeriod->OnChangedDelegate().AddUObject(this, &UCEClonerSubsystem::OnTSRShadingRejectionFlickeringPeriodChanged);
	}
#endif

#Loc: <Workspace>/Engine/Plugins/Experimental/ClonerEffector/Source/ClonerEffector/Public/Cloner/CEClonerActor.h:598

Scope (from outer to inner):

file
class        class ACEClonerActor : public AActor

Source code excerpt:

	bool bVisualizerSpriteVisible = true;

	/** Reduces the r.TSR.ShadingRejection.Flickering.Period from 3 (default) to 1 if enabled to avoid ghosting artifacts when moving */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category="Cloner", meta=(AllowPrivateAccess = "true"))
	bool bReduceMotionGhosting = false;
#endif

private:
#if WITH_EDITOR

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRFlickeringPeriod(
	TEXT("r.TSR.ShadingRejection.Flickering.Period"), 2.0f,
	TEXT("Periode in frames in which luma oscilations at equal or greater frequency is considered flickering and should ghost to stabilize the image ")
	TEXT("Please read r.TSR.ShadingRejection.Flickering's help for further details. (Default to 3 frames)."),
	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRFlickeringMaxParralaxVelocity(

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:


	// period at which history changes is considered too distracting.
	const float FlickeringFramePeriod = CVarTSRFlickeringEnable.GetValueOnRenderThread() ? (CVarTSRFlickeringPeriod.GetValueOnRenderThread() / FMath::Max(RefreshRateToFrameRateCap, 1.0f)) : 0.0f;

	ETSRHistoryFormatBits HistoryFormatBits = ETSRHistoryFormatBits::None;
	{
		if (FlickeringFramePeriod > 0)
		{
			HistoryFormatBits |= ETSRHistoryFormatBits::Moire;