r.TSR.ShadingRejection.ExposureOffset

r.TSR.ShadingRejection.ExposureOffset

#Overview

name: r.TSR.ShadingRejection.ExposureOffset

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.TSR.ShadingRejection.ExposureOffset is to adjust the exposure offset for the shading rejection process in Unreal Engine 5’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 in the Temporal Super Resolution subsystem. It’s referenced in the TemporalSuperResolution.cpp file, which is responsible for implementing the TSR algorithm.

The value of this variable is set through the console variable system, with a default value of 3.0. It can be modified at runtime using console commands or through project settings.

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

Developers must be aware that this variable affects how the TSR system perceives and processes color intensity. It’s crucial for detecting changes in color that might be visible in the back buffer and for preventing ghosting artifacts in subtle visual effects.

Best practices when using this variable include:

  1. Carefully adjusting the value to balance between detecting subtle color changes and avoiding over-sensitivity to minor variations.
  2. Testing the impact of changes across a range of scenes and lighting conditions to ensure optimal performance.
  3. Monitoring performance and visual quality when modifying this value, as it can affect the overall TSR effectiveness.

Regarding the associated variable CVarTSRShadingExposureOffset:

The purpose of CVarTSRShadingExposureOffset is identical to r.TSR.ShadingRejection.ExposureOffset. It’s used internally in the C++ code to access and apply the exposure offset value in various TSR-related computations.

This variable is used in several key functions within the TSR system, including:

The value of CVarTSRShadingExposureOffset is typically accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in render thread operations.

Developers should be aware that modifying CVarTSRShadingExposureOffset directly in code will have the same effect as changing r.TSR.ShadingRejection.ExposureOffset through console commands or project settings.

Best practices for using CVarTSRShadingExposureOffset include:

  1. Accessing the value consistently using GetValueOnRenderThread() in render thread operations.
  2. Considering the performance implications of frequently querying this value in performance-critical code paths.
  3. Documenting any hard-coded uses of this variable to maintain consistency with the engine’s configurable settings.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTSRShadingExposureOffset(
	TEXT("r.TSR.ShadingRejection.ExposureOffset"), 3.0,
	TEXT("The shading rejection needs to have a representative idea how bright a linear color pixel ends up displayed to the user. ")
	TEXT("And the shading rejection detect if a color become to changed to be visible in the back buffer by comparing to MeasureBackbufferLDRQuantizationError().\n")
	TEXT("\n")
	TEXT("It is important to have TSR's MeasureBackbufferLDRQuantizationError() ends up distributed uniformly across ")
	TEXT("the range of color intensity or it could otherwise disregard some subtle VFX causing ghostin.\n")
	TEXT("\n")

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<float> CVarTSRShadingExposureOffset(
	TEXT("r.TSR.ShadingRejection.ExposureOffset"), 3.0,
	TEXT("The shading rejection needs to have a representative idea how bright a linear color pixel ends up displayed to the user. ")
	TEXT("And the shading rejection detect if a color become to changed to be visible in the back buffer by comparing to MeasureBackbufferLDRQuantizationError().\n")
	TEXT("\n")
	TEXT("It is important to have TSR's MeasureBackbufferLDRQuantizationError() ends up distributed uniformly across ")
	TEXT("the range of color intensity or it could otherwise disregard some subtle VFX causing ghostin.\n")

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

Scope (from outer to inner):

file
function     FScreenPassTexture AddTSRMeasureFlickeringLuma

Source code excerpt:

	PassParameters->InputInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
		SceneColor.Texture->Desc.Extent, SceneColor.ViewRect));
	PassParameters->PerceptionAdd = FMath::Pow(0.5f, CVarTSRShadingExposureOffset.GetValueOnRenderThread());
	PassParameters->SceneColorTexture = SceneColor.Texture;
	PassParameters->FlickeringLumaOutput = GraphBuilder.CreateUAV(FlickeringLuma.Texture);

	TShaderMapRef<FTSRMeasureFlickeringLumaCS> ComputeShader(ShaderMap);
	FComputeShaderUtils::AddPass(
		GraphBuilder,

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:

			PassParameters->ResurrectionGuideUVViewportBilinearMax = GetScreenPassTextureViewportParameters(ResurrectionGuideViewport).UVViewportBilinearMax;
			PassParameters->HistoryGuideQuantizationError = ComputePixelFormatQuantizationError(PrevHistory.GuideArray->Desc.Format);
			PassParameters->PerceptionAdd = FMath::Pow(0.5f, CVarTSRShadingExposureOffset.GetValueOnRenderThread());
		}

		PassParameters->ResurrectionFrameIndex = ResurrectionFrameSliceIndex;
		PassParameters->PrevFrameIndex = PrevFrameSliceIndex;
		PassParameters->ClipToResurrectionClip = ClipToResurrectionClip;

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses

Source code excerpt:

		PassParameters->TheoricBlendFactor = 1.0f / (1.0f + MaxHistorySampleCount / OutputToInputResolutionFractionSquare);
		PassParameters->TileOverscan = TileOverscan;
		PassParameters->PerceptionAdd = FMath::Pow(0.5f, CVarTSRShadingExposureOffset.GetValueOnRenderThread());
		PassParameters->bEnableResurrection = bCanResurrectHistory;
		PassParameters->bEnableFlickeringHeuristic = FlickeringFramePeriod > 0.0f;

		PassParameters->InputTexture = PassInputs.SceneColor.Texture;
		if (PassInputs.FlickeringInputTexture.IsValid())
		{

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

Scope (from outer to inner):

file
function     FDefaultTemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses
lambda-function

Source code excerpt:

			PassParameters->OutputToHistoryResolutionFractionSquare = OutputToHistoryResolutionFractionSquare;
			PassParameters->FlickeringFramePeriod = FlickeringFramePeriod;
			PassParameters->PerceptionAdd = FMath::Pow(0.5f, CVarTSRShadingExposureOffset.GetValueOnRenderThread());

			PassParameters->InputTexture = PassInputs.SceneColor.Texture;
			if (PassInputs.FlickeringInputTexture.IsValid())
			{
				ensure(InputRect == PassInputs.FlickeringInputTexture.ViewRect);
				PassParameters->InputMoireLumaTexture = PassInputs.FlickeringInputTexture.Texture;