r.Refraction.Blur.TemporalAA

r.Refraction.Blur.TemporalAA

#Overview

name: r.Refraction.Blur.TemporalAA

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.Refraction.Blur.TemporalAA is to enable temporal anti-aliasing (TAA) of the scene color buffer to reduce flickering in rough refractions. This setting is part of the rendering system in Unreal Engine 5, specifically targeting the refraction and distortion rendering process.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the distortion rendering subsystem. Based on the callsites, it’s clear that this variable is utilized in the DistortionRendering.cpp file, which is responsible for handling refraction and distortion effects in the engine.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning it’s enabled by default. Developers can change this value at runtime using console commands or through project settings.

The associated variable CVarRefractionBlurTemporalAA interacts directly with r.Refraction.Blur.TemporalAA. They share the same value and purpose, with CVarRefractionBlurTemporalAA being the actual C++ variable used in the code to access the setting.

Developers should be aware that this variable affects the visual quality and performance of refraction effects. Enabling this feature (value > 0) will apply temporal anti-aliasing to the scene color buffer, which can improve the visual quality of rough refractions by reducing flickering. However, it may also have a performance impact.

Best practices when using this variable include:

  1. Consider the performance impact when enabling this feature, especially on lower-end hardware.
  2. Test the visual difference with the setting on and off to determine if the quality improvement justifies any potential performance cost.
  3. Use in conjunction with other refraction-related settings to achieve the desired visual quality.

Regarding the associated variable CVarRefractionBlurTemporalAA:

The purpose of CVarRefractionBlurTemporalAA is to provide a programmatic way to access and modify the r.Refraction.Blur.TemporalAA setting within the C++ code of Unreal Engine.

This variable is used directly in the Renderer module, specifically in the distortion rendering process. It’s accessed in the RenderDistortion function of the FDeferredShadingSceneRenderer class.

The value of CVarRefractionBlurTemporalAA is set through the CVar system, mirroring the value of r.Refraction.Blur.TemporalAA.

Developers should be aware that this variable is checked on the render thread (using GetValueOnRenderThread()), which is important for thread safety in rendering operations.

Best practices for using CVarRefractionBlurTemporalAA include:

  1. Always access its value using GetValueOnRenderThread() when in rendering code to ensure thread safety.
  2. Be cautious about changing its value during runtime, as it may affect ongoing rendering processes.
  3. Consider exposing this setting in user-facing graphics options if refraction quality is an important aspect of your game’s visuals.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:47

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRefractionBlurTemporalAA(
	TEXT("r.Refraction.Blur.TemporalAA"),
	1,
	TEXT("Enables temporal AA of the scene color buffer in order to avoid flickering in rough refractions."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRefractionBlurMaxExposedLuminance(
	TEXT("r.Refraction.Blur.MaxExposedLuminance"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:46

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRefractionBlurTemporalAA(
	TEXT("r.Refraction.Blur.TemporalAA"),
	1,
	TEXT("Enables temporal AA of the scene color buffer in order to avoid flickering in rough refractions."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRefractionBlurMaxExposedLuminance(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:569

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderDistortion

Source code excerpt:


			FRDGTextureRef TAASceneColorTexture = SceneColorTexture;
			if(View.ViewState && CVarRefractionBlurTemporalAA.GetValueOnRenderThread() > 0)
			{
				FTAAPassParameters TAASettings(View);
				TAASettings.SceneDepthTexture = SceneDepthTexture;
				TAASettings.SceneVelocityTexture = SceneVelocityTexture;
				TAASettings.Pass = ETAAPassConfig::Main;		// Reusing main config for now. We could add a ReoughRefraction config forcing 111110 format.
				TAASettings.SceneColorInput = TAASceneColorTexture;