r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity

r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity

#Overview

name: r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity

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.ShadingRejection.Flickering.MaxParallaxVelocity is to control the maximum parallax velocity threshold for the Temporal Super Resolution (TSR) shading rejection system, specifically addressing flickering issues in materials with parallax occlusion mapping.

This setting variable is primarily used in the rendering system, specifically within the Temporal Super Resolution module of Unreal Engine 5. It’s part of the post-processing pipeline and is utilized in the TemporalSuperResolution.cpp file.

The value of this variable is set as a console variable with a default value of 10.0. It can be adjusted at runtime through the console or configuration files.

This variable interacts closely with another variable, CVarTSRFlickeringMaxParralaxVelocity, which is its associated console variable. They share the same value and purpose.

Developers must be aware that this variable is specifically designed to handle flickering issues in materials that use techniques like parallax occlusion mapping. It’s particularly relevant for scenarios where accurate motion vectors for fake interior geometry (like building windows in CitySample) are difficult to render.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project, especially if you’re using parallax occlusion mapping or similar techniques.
  2. Understanding that it’s measured in 1080p pixels at the frame rate defined by r.TSR.ShadingRejection.Flickering.FrameRateCap.
  3. Being cautious when modifying it, as it can affect the balance between flickering reduction and potential ghosting artifacts.

Regarding the associated variable CVarTSRFlickeringMaxParralaxVelocity:

The purpose of CVarTSRFlickeringMaxParralaxVelocity is identical to r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity. It’s the console variable implementation of the same setting.

This variable is used in the same Temporal Super Resolution module and is referenced in the same TemporalSuperResolution.cpp file.

The value is set and accessed using the TAutoConsoleVariable template class, which allows for runtime modification.

It interacts directly with r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity, as they represent the same setting.

Developers should be aware that this is the actual variable used in the code to retrieve the setting’s value, typically through the GetValueOnRenderThread() method.

Best practices include using this variable when you need to programmatically access or modify the MaxParallaxVelocity setting in C++ code, particularly within render thread operations.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTSRFlickeringMaxParralaxVelocity(
	TEXT("r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity"), 10.0,
	TEXT("Some material might for instance might do something like parallax occlusion mapping such as CitySample's buildings' window's interiors. ")
	TEXT("This often can not render accurately a motion vector of this fake interior geometry and therefore make the heuristic believe it is in fact flickering.\n")
	TEXT("\n")
	TEXT("This variable define the parallax velocity in 1080p pixel at frame rate defined by r.TSR.ShadingRejection.Flickering.FrameRateCap at which point the ")
	TEXT("heuristic should be disabled to not ghost. ")
	TEXT("\n")

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRFlickeringMaxParralaxVelocity(
	TEXT("r.TSR.ShadingRejection.Flickering.MaxParallaxVelocity"), 10.0,
	TEXT("Some material might for instance might do something like parallax occlusion mapping such as CitySample's buildings' window's interiors. ")
	TEXT("This often can not render accurately a motion vector of this fake interior geometry and therefore make the heuristic believe it is in fact flickering.\n")
	TEXT("\n")
	TEXT("This variable define the parallax velocity in 1080p pixel at frame rate defined by r.TSR.ShadingRejection.Flickering.FrameRateCap at which point the ")
	TEXT("heuristic should be disabled to not ghost. ")

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:

		PassParameters->VelocityExtrapolationMultiplier = 0.0; //FMath::Clamp(CVarTSRVelocityExtrapolation.GetValueOnRenderThread(), 0.0f, 1.0f);
		{
			float FlickeringMaxParralaxVelocity = RefreshRateToFrameRateCap * CVarTSRFlickeringMaxParralaxVelocity.GetValueOnRenderThread() * float(View.ViewRect.Width()) / 1920.0f;
			PassParameters->InvFlickeringMaxParralaxVelocity = 1.0f / FlickeringMaxParralaxVelocity;
		}
		PassParameters->bOutputIsMovingTexture = bOutputIsMovingTexture;
		
		PassParameters->SceneDepthTexture = PassInputs.SceneDepth.Texture;
		PassParameters->SceneVelocityTexture = PassInputs.SceneVelocity.Texture;