ShowFlag.TemporalAA

ShowFlag.TemporalAA

#Overview

name: ShowFlag.TemporalAA

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

It is referenced in 18 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.TemporalAA is to control the visibility and usage of Temporal Anti-Aliasing (TAA) in Unreal Engine’s rendering pipeline. Temporal Anti-Aliasing is an advanced anti-aliasing technique that uses information from previous frames to reduce aliasing artifacts and improve image quality.

This setting variable is primarily used by the rendering system, specifically the post-processing and anti-aliasing subsystems. Based on the provided code references, it is utilized in various Unreal Engine modules and plugins, including:

  1. Engine module
  2. Renderer module
  3. Composure plugin
  4. nDisplay plugin
  5. FunctionalTesting module

The value of this variable is typically set in different parts of the engine:

  1. In the SceneCaptureComponent2D constructor, it’s set to false by default.
  2. In the CompositingCaptureBase constructor, it’s set to true.
  3. It can be modified through the UAutomationViewSettings class.
  4. It can be toggled in the engine’s show flags system.

Several other variables and systems interact with ShowFlag.TemporalAA:

  1. It’s often used in conjunction with ShowFlag.AntiAliasing.
  2. It affects the choice of anti-aliasing method in FSceneView::SetupAntiAliasingMethod.
  3. It’s used in conjunction with the TemporalAASampleIndex in the view state.

Developers should be aware of the following when using this variable:

  1. Enabling Temporal AA may have performance implications, especially on lower-end hardware.
  2. It may not be supported on all platforms or rendering configurations.
  3. It can affect the visual quality and stability of the rendered image, especially for moving objects.

Best practices for using this variable include:

  1. Consider the target platform and hardware capabilities when enabling or disabling Temporal AA.
  2. Test the visual quality and performance impact thoroughly when modifying this setting.
  3. Be aware of its interaction with other anti-aliasing methods and post-processing effects.

Regarding the associated variable TemporalAA:

The purpose of TemporalAA is similar to ShowFlag.TemporalAA, but it’s used in different contexts, such as in the UAutomationViewSettings class and as an enum value in the EMobileAntiAliasingMethod.

It’s primarily used in the automation and testing systems, as well as in mobile rendering configurations. Developers should be aware that this variable might affect how anti-aliasing is applied in different rendering scenarios, especially in mobile or automated testing environments.

When using TemporalAA, consider the specific context (e.g., mobile rendering, automated testing) and ensure that the chosen anti-aliasing method is appropriate for the target platform and use case.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:29

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(AntiAliasing, SFG_Normal, NSLOCTEXT("UnrealEd", "AntiAliasingSF", "Anti-aliasing"))
/** Only used in AntiAliasing is on, true:uses Temporal AA, otherwise FXAA, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture  */
SHOWFLAG_ALWAYS_ACCESSIBLE(TemporalAA, SFG_Advanced, NSLOCTEXT("UnrealEd", "TemporalAASF", "Temporal AA (instead FXAA)"))
/** e.g. Ambient cube map, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(AmbientCubemap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "AmbientCubemapSF", "Ambient Cubemap"))
/** Human like eye simulation to adapt to the brightness of the view, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(EyeAdaptation, SFG_PostProcess, NSLOCTEXT("UnrealEd", "EyeAdaptationSF", "Eye Adaptation"))
/** Display a histogram of the scene HDR color */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeHDR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeHDRSF", "HDR (Eye Adaptation)"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Compositing/Composure/Source/Composure/Private/CompositingCaptureBase.cpp:16

Scope (from outer to inner):

file
function     ACompositingCaptureBase::ACompositingCaptureBase

Source code excerpt:


	// The SceneCaptureComponent2D default constructor disables TAA, but CG Compositing Elements enable it by default
	SceneCaptureComponent2D->ShowFlags.TemporalAA = true;
}

void ACompositingCaptureBase::PostInitProperties()
{
	Super::PostInitProperties();
	EObjectFlags ExcludeFlags = RF_ArchetypeObject | RF_ClassDefaultObject | RF_NeedLoad | RF_NeedPostLoad | RF_NeedPostLoadSubobjects | RF_WasLoaded;

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayCluster/Private/Render/Viewport/Preview/DisplayClusterViewportManagerPreview_Render.cpp:153

Scope (from outer to inner):

file
function     bool FDisplayClusterViewportManagerPreview::InitializeClusterNodePreview

Source code excerpt:

						if (RenderTargetIt.CaptureMode == EDisplayClusterViewportCaptureMode::Default && Configuration->GetRenderFrameSettings().IsPostProcessDisabled())
						{
							if (ViewFamily->EngineShowFlags.TemporalAA)
							{
								ViewFamily->EngineShowFlags.SetTemporalAA(false);
								ViewFamily->EngineShowFlags.SetAntiAliasing(true);
							}
						}

#Loc: <Workspace>/Engine/Plugins/VirtualProduction/TextureShare/Source/TextureShareCore/Private/Containers/TextureShareCoreContainers_SceneData.h:34

Scope: file

Source code excerpt:

	FVector2D ProjectionScale;

	// TemporalAA jitter offset currently stored in the projection matrix
	FVector2D TemporalAAProjectionJitter;

	// Scale factor to use when computing the size of a sphere in pixels.
	float ScreenScale = 1.f;

public:

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/AutomationBlueprintFunctionLibrary.cpp:186

Scope (from outer to inner):

file
class        class FAutomationViewExtension : public FWorldSceneViewExtension
function     virtual void SetupViewFamily

Source code excerpt:

			ShowFlags.SetAntiAliasing(ViewSettings->AntiAliasing);
			ShowFlags.SetMotionBlur(ViewSettings->MotionBlur);
			ShowFlags.SetTemporalAA(ViewSettings->TemporalAA);
			ShowFlags.SetScreenSpaceReflections(ViewSettings->ScreenSpaceReflections);
			ShowFlags.SetScreenSpaceAO(ViewSettings->ScreenSpaceAO);
			ShowFlags.SetDistanceFieldAO(ViewSettings->DistanceFieldAO);
			ShowFlags.SetContactShadows(ViewSettings->ContactShadows);
			ShowFlags.SetEyeAdaptation(ViewSettings->EyeAdaptation);
			ShowFlags.SetBloom(ViewSettings->Bloom);

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Public/AutomationViewSettings.h:17

Scope (from outer to inner):

file
class        class UAutomationViewSettings : public UDataAsset
function     UAutomationViewSettings

Source code excerpt:

		: AntiAliasing(true)
		, MotionBlur(true)
		, TemporalAA(true)
		, ScreenSpaceReflections(true)
		, ScreenSpaceAO(true)
		, DistanceFieldAO(true)
		, ContactShadows(true)
		, EyeAdaptation(true)
		, Bloom(true)

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Public/AutomationViewSettings.h:34

Scope (from outer to inner):

file
class        class UAutomationViewSettings : public UDataAsset

Source code excerpt:

	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool TemporalAA;
	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool ScreenSpaceReflections;
	
	UPROPERTY(EditAnywhere, Category="Rendering")
	bool ScreenSpaceAO;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:192

Scope (from outer to inner):

file
namespace    EMobileAntiAliasingMethod

Source code excerpt:

		None = AAM_None UMETA(DisplayName = "None"),
		FXAA = AAM_FXAA UMETA(DisplayName = "Fast Approximate Anti-Aliasing (FXAA)"),
		TemporalAA = AAM_TemporalAA UMETA(DisplayName = "Temporal Anti-Aliasing (TAA)"),
		/** Only supported with forward shading.  MSAA sample count is controlled by r.MSAACount. */
		MSAA = AAM_MSAA UMETA(DisplayName = "Multisample Anti-Aliasing (MSAA)"),
	};
}

/** The default float precision for material's pixel shaders on mobile devices*/

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SceneCaptureComponent.cpp:583

Scope (from outer to inner):

file
function     USceneCaptureComponent2D::USceneCaptureComponent2D

Source code excerpt:


		// previous behavior was not exposing MotionBlur and Temporal AA in scene capture 2d.
		ShowFlags.TemporalAA = false;
		ShowFlags.MotionBlur = false;

#if WITH_EDITORONLY_DATA
		if (!IsRunningCommandlet())
		{
			static ConstructorHelpers::FObjectFinder<UStaticMesh> EditorMesh(TEXT("/Engine/EditorMeshes/MatineeCam_SM"));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/SceneCaptureComponent.cpp:864

Scope (from outer to inner):

file
function     void USceneCaptureComponent2D::Serialize

Source code excerpt:

		if (Ar.CustomVer(FRenderingObjectVersion::GUID) < FRenderingObjectVersion::MotionBlurAndTAASupportInSceneCapture2d)
		{
			ShowFlags.TemporalAA = false;
			ShowFlags.MotionBlur = false;
		}

#if WITH_EDITOR
		if (Ar.CustomVer(FFortniteMainBranchObjectVersion::GUID) < FFortniteMainBranchObjectVersion::OrthographicCameraDefaultSettings && bUseFauxOrthoViewPos)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LocalPlayer.cpp:1513

Scope (from outer to inner):

file
function     bool ULocalPlayer::Exec

Source code excerpt:

	else if (FParse::Command(&Cmd, TEXT("r.ResetViewState")))
	{
		// Reset states (e.g. TemporalAA index) to make rendering more deterministic (for automated screenshot verification)
		for (auto& State : ViewStates)
		{
			if (FSceneViewStateInterface* Ref = State.GetReference())
			{
				Ref->ResetViewState();
			}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:1115

Scope (from outer to inner):

file
function     void FSceneView::SetupAntiAliasingMethod

Source code excerpt:

		if (AntiAliasingMethod == AAM_TemporalAA)
		{
			if (!Family->EngineShowFlags.TemporalAA || !Family->bRealtimeUpdate || !SupportsGen4TAA(GetShaderPlatform()))
			{
				AntiAliasingMethod = AAM_FXAA;
			}
		}
		else if (AntiAliasingMethod == AAM_TSR)
		{
			// TODO(TSR): Support TSR with bRealtimeUpdate
			if (!Family->EngineShowFlags.TemporalAA || !Family->bRealtimeUpdate || !SupportsTSR(GetShaderPlatform()))
			{
				AntiAliasingMethod = AAM_FXAA;
			}
		}

		checkf(Family->GetTemporalUpscalerInterface() == nullptr, TEXT("ITemporalUpscaler should be set up in FSceneViewExtensionBase::BeginRenderViewFamily()"));
	}

	// TemporalAA requires view state for history.
	if (IsTemporalAccumulationBasedMethod(AntiAliasingMethod) && !State)
	{
		AntiAliasingMethod = AAM_None;
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/GPUSkinCache.h:14

Scope: file

Source code excerpt:

// * Supports Morph target animation (morph target blending is not done by this code)
// * Saves vertex shader computations when we render an object multiple times (EarlyZ, velocity, shadow, BasePass, CustomDepth, Shadow masking)
// * Fixes velocity rendering (needed for MotionBlur and TemporalAA) for WorldPosOffset animation and morph target animation
// * RecomputeTangents results in improved tangent space for WorldPosOffset animation and morph target animation
// * fixed amount of memory per Scene (r.SkinCache.SceneMemoryLimitInMB)
// * Velocity Rendering for MotionBlur and TemporalAA (test Velocity in BasePass)
// * r.SkinCache.Mode and r.SkinCache.RecomputeTangents can be toggled at runtime

// TODO:
// * Test: Tessellation
// * Quality/Optimization: increase TANGENT_RANGE for better quality or accumulate two components in one 32bit value
// * Bug: UpdateMorphVertexBuffer needs to handle SkinCacheObjects that have been rejected by the SkinCache (e.g. because it was running out of memory)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/SceneView.h:362

Scope: file

Source code excerpt:

	/** Scale applied by the projection matrix in X and Y. */
	FVector2D	ProjectionScale;
	/** TemporalAA jitter offset currently stored in the projection matrix */
	FVector2D	TemporalAAProjectionJitter;

	/**
	 * Scale factor to use when computing the size of a sphere in pixels.
	 * 
	 * A common calculation is to determine the size of a sphere in pixels when projected on the screen:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:29

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(AntiAliasing, SFG_Normal, NSLOCTEXT("UnrealEd", "AntiAliasingSF", "Anti-aliasing"))
/** Only used in AntiAliasing is on, true:uses Temporal AA, otherwise FXAA, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture  */
SHOWFLAG_ALWAYS_ACCESSIBLE(TemporalAA, SFG_Advanced, NSLOCTEXT("UnrealEd", "TemporalAASF", "Temporal AA (instead FXAA)"))
/** e.g. Ambient cube map, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(AmbientCubemap, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "AmbientCubemapSF", "Ambient Cubemap"))
/** Human like eye simulation to adapt to the brightness of the view, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(EyeAdaptation, SFG_PostProcess, NSLOCTEXT("UnrealEd", "EyeAdaptationSF", "Eye Adaptation"))
/** Display a histogram of the scene HDR color */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeHDR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeHDRSF", "HDR (Eye Adaptation)"))

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

Scope (from outer to inner):

file
namespace    anonymous
class        class FTemporalAA : public FGlobalShader
function     class FTAAScreenPercentageDim : SHADER_PERMUTATION_INT
class        class FTAAScreenPercentageDim : SHADER_PERMUTATION_INT("TAA_SCREEN_PERCENTAGE_RANGE", 4); BEGIN_SHADER_PARAMETER_STRUCT(FParameters, ) SHADER_PARAMETER(FVector4f, ViewportUVToInputBufferUV) SHADER_PARAMETER(FVector4f, MaxViewportUVAndSvPositionToViewportUV) SHADER_PARAMETER(FVector2f, ScreenPosAbsMax) SHADER_PARAMETER(float, HistoryPreExposureCorrection) SHADER_PARAMETER(float, CurrentFrameWeight) SHADER_PARAMETER(int32, bCameraCut) SHADER_PARAMETER_SCALAR_ARRAY(float, SampleWeights, [9]) SHADER_PARAMETER_SCALAR_ARRAY(float, PlusWeights, [5]) SHADER_PARAMETER(FVector4f, InputSceneColorSize) SHADER_PARAMETER(FIntPoint, InputMinPixelCoord) SHADER_PARAMETER(FIntPoint, InputMaxPixelCoord) SHADER_PARAMETER(FVector4f, OutputViewportSize) SHADER_PARAMETER(FVector4f, OutputViewportRect) SHADER_PARAMETER(FVector3f, OutputQuantizationError) SHADER_PARAMETER(FVector4f, HistoryBufferSize) SHADER_PARAMETER(FVector4f, HistoryBufferUVMinMax) SHADER_PARAMETER(FVector4f, ScreenPosToHistoryBufferUV) SHADER_PARAMETER(FVector4f, InputViewSize) SHADER_PARAMETER(FVector2f, InputViewMin) SHADER_PARAMETER(FVector2f, TemporalJitterPixels) SHADER_PARAMETER(float, ScreenPercentage) SHADER_PARAMETER(float, UpscaleFactor) SHADER_PARAMETER_RDG_BUFFER_SRV(StructuredBuffer<float4>, EyeAdaptationBuffer) SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneColor) SHADER_PARAMETER_SAMPLER(SamplerState, InputSceneColorSampler) SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneMetadata) SHADER_PARAMETER_SAMPLER(SamplerState, InputSceneMetadataSampler) SHADER_PARAMETER_RDG_TEXTURE_ARRAY(Texture2D, HistoryBuffer, [FTemporalAAHistory::kRenderTargetCount]) SHADER_PARAMETER_SAMPLER_ARRAY(SamplerState, HistoryBufferSampler, [FTemporalAAHistory::kRenderTargetCount]) SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneDepthTexture) SHADER_PARAMETER_SAMPLER(SamplerState, SceneDepthTextureSampler) SHADER_PARAMETER_RDG_TEXTURE(Texture2D, GBufferVelocityTexture) SHADER_PARAMETER_SAMPLER(SamplerState, GBufferVelocityTextureSampler) SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, GBufferVelocityTextureSRV) SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, StencilTexture) SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer) END_SHADER_PARAMETER_STRUCT() static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment) { static FShaderPlatformCachedIniValue<bool> UseMobileConfig(TEXT("r.TemporalAA.UseMobileConfig")); bool bUseMobileConfig = (UseMobileConfig.Get((EShaderPlatform)Parameters.Platform) != 0); bool bIsMobileTiledGPU = RHIHasTiledGPU(Parameters.Platform) || IsSimulatedPlatform(Parameters.Platform); OutEnvironment.SetDefine(TEXT("AA_MOBILE_CONFIG"), (bIsMobileTiledGPU || bUseMobileConfig) ? 1 : 0); }

Source code excerpt:

	static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
	{
		static FShaderPlatformCachedIniValue<bool> UseMobileConfig(TEXT("r.TemporalAA.UseMobileConfig"));
		bool bUseMobileConfig = (UseMobileConfig.Get((EShaderPlatform)Parameters.Platform) != 0);

		bool bIsMobileTiledGPU = RHIHasTiledGPU(Parameters.Platform) || IsSimulatedPlatform(Parameters.Platform);

		// There are some mobile specific shader optimizations need to be set in the shader, such as disable shared memory usage, disable stencil texture sampling.
		OutEnvironment.SetDefine(TEXT("AA_MOBILE_CONFIG"), (bIsMobileTiledGPU || bUseMobileConfig) ? 1 : 0);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScenePrivate.h:992

Scope: file

Source code excerpt:

public:
	
	// if TemporalAA is on this cycles through 0..TemporalAASampleCount-1, ResetViewState() puts it back to 0
	int32 TemporalAASampleIndex;

	// counts up by one each frame, warped in 0..7 range, ResetViewState() puts it back to 0
	uint32 FrameIndex;
	
	/** Informations of to persist for the next frame's FViewInfo::PrevViewInfo.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:314

Scope (from outer to inner):

file
namespace    anonymous
function     FLinearColor ComputeSSRParams

Source code excerpt:

		if(bTemporalAAIsOn)
		{
			// usually this number is in the 0..7 range but it depends on the TemporalAA quality
			FrameRandom = View.ViewState->GetCurrentTemporalAASampleIndex() * 1551;
		}
		else
		{
			// 8 aligns with the temporal smoothing, larger number will do more flickering (power of two for best performance)
			FrameRandom = View.ViewState->GetFrameIndex(8) * 1551;