r.TemporalAAFilterSize

r.TemporalAAFilterSize

#Overview

name: r.TemporalAAFilterSize

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.TemporalAAFilterSize is to control the size of the filter kernel used in Temporal Anti-Aliasing (TAA) in Unreal Engine 5’s rendering system. It affects the balance between smoothness and sharpness in the final rendered image.

This setting variable is primarily used in the Renderer subsystem of Unreal Engine 5. Specifically, it’s utilized in the Temporal Anti-Aliasing implementation, which is a crucial part of the post-processing pipeline.

The value of this variable is set through the console variable system. It’s initialized with a default value of 1.0f, but can be changed at runtime using console commands or through engine configuration files.

The r.TemporalAAFilterSize interacts closely with the CVarTemporalAAFilterSize variable, which is its associated console variable. They share the same value and are used interchangeably in different parts of the code.

Developers must be aware that this variable directly impacts the visual quality and performance of the TAA implementation. A larger value (closer to 1.0) will result in a smoother image but may introduce more blur, while a smaller value (closer to 0.0) will produce a sharper but potentially more aliased image.

Best practices when using this variable include:

  1. Fine-tuning the value based on the specific needs of your project, balancing between image quality and performance.
  2. Testing different values in various scenarios to ensure consistent visual quality across different scenes and camera movements.
  3. Considering the target hardware when setting this value, as higher values may have a greater performance impact on lower-end devices.

Regarding the associated variable CVarTemporalAAFilterSize:

The purpose of CVarTemporalAAFilterSize is to provide a console-accessible interface for the r.TemporalAAFilterSize setting. It allows for real-time adjustment of the TAA filter size through console commands.

This variable is used directly in the Temporal Anti-Aliasing implementation within the Renderer module. It’s typically accessed using GetValueOnRenderThread() to ensure thread-safe access to its current value.

The value of CVarTemporalAAFilterSize is set when the console variable is initialized, but can be modified at runtime through console commands.

CVarTemporalAAFilterSize interacts closely with other TAA-related variables, such as CVarTemporalAACatmullRom, which together control various aspects of the TAA implementation.

Developers should be aware that changes to CVarTemporalAAFilterSize will immediately affect the rendering output, making it useful for real-time tweaking and debugging of TAA settings.

Best practices for using CVarTemporalAAFilterSize include:

  1. Using it for quick iterations and testing of different TAA filter sizes during development.
  2. Documenting the final chosen value for use in production builds.
  3. Considering exposing this setting (with appropriate limits) to end-users if fine control over TAA is desired in the final product.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalAA.cpp:20

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<float> CVarTemporalAAFilterSize(
	TEXT("r.TemporalAAFilterSize"),
	1.0f,
	TEXT("Size of the filter kernel. (1.0 = smoother, 0.0 = sharper but aliased)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarTemporalAACatmullRom(
	TEXT("r.TemporalAACatmullRom"),

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineUtils.cpp:1075

Scope (from outer to inner):

file
namespace    UE
namespace    MoviePipeline
function     FVector2f GetSubPixelJitter

Source code excerpt:

			float SpatialShiftY = 0.0f;

			static auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAAFilterSize"));
			float FilterSize = CVar->GetFloat();

			// Scale distribution to set non-unit variance
			// Variance = Sigma^2
			float Sigma = 0.47f * FilterSize;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4972

Scope: file

Source code excerpt:

				// exp( x^2 / Sigma^2 )
					
				static auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAAFilterSize"));
				float FilterSize = CVar->GetFloat();

				// Scale distribution to set non-unit variance
				// Variance = Sigma^2
				float Sigma = 0.47f * FilterSize;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalAA.cpp:19

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

const int32 GTemporalAATileSizeY = 8;

TAutoConsoleVariable<float> CVarTemporalAAFilterSize(
	TEXT("r.TemporalAAFilterSize"),
	1.0f,
	TEXT("Size of the filter kernel. (1.0 = smoother, 0.0 = sharper but aliased)."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarTemporalAACatmullRom(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalAA.cpp:379

Scope (from outer to inner):

file
namespace    anonymous
function     void SetupSampleWeightParameters

Source code excerpt:

	};

	float FilterSize = CVarTemporalAAFilterSize.GetValueOnRenderThread();
	int32 bCatmullRom = CVarTemporalAACatmullRom.GetValueOnRenderThread();

	// Compute 3x3 weights
	{
		float TotalWeight = 0.0f;
		for (int32 i = 0; i < 9; i++)