r.GTAO.FilterWidth

r.GTAO.FilterWidth

#Overview

name: r.GTAO.FilterWidth

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.GTAO.FilterWidth is to control the size of the noise pattern and filter width for Ground Truth Ambient Occlusion (GTAO) in Unreal Engine’s rendering system.

This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the post-processing and ambient occlusion components. It’s part of the CompositionLighting module, as evidenced by its location in the PostProcessAmbientOcclusion.cpp file.

The value of this variable is set through a console variable (CVarGTAOFilterWidth) with a default value of 5. It can be changed at runtime using console commands or through project settings.

The associated variable CVarGTAOFilterWidth directly interacts with r.GTAO.FilterWidth, as they share the same value. This console variable is used to retrieve the current filter width value in the rendering code.

Developers should be aware that:

  1. The filter width affects the quality and performance of the GTAO effect.
  2. Only two options are explicitly mentioned in the comments: 5x5 (default) and 4x4 patterns.
  3. The variable is marked as render thread safe and scalable, meaning it can be adjusted for different performance levels.

Best practices when using this variable include:

  1. Consider the performance implications when adjusting the filter width. A larger filter may provide better quality but at a higher performance cost.
  2. Use the provided options (5 or 4) unless there’s a specific need for other values.
  3. Test the visual impact and performance when changing this value, as it directly affects the GTAO calculation.

Regarding the associated variable CVarGTAOFilterWidth:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:104

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarGTAOFilterWidth(
	TEXT("r.GTAO.FilterWidth"),
	5,
	TEXT("Size of the noise pattern and filter width\n ")
	TEXT("5: 5x5 Pattern (default) \n ")
	TEXT("4: 4x4 Pattern \n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:103

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarGTAOFilterWidth(
	TEXT("r.GTAO.FilterWidth"),
	5,
	TEXT("Size of the noise pattern and filter width\n ")
	TEXT("5: 5x5 Pattern (default) \n ")
	TEXT("4: 4x4 Pattern \n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:1555

Scope (from outer to inner):

file
function     FScreenPassTexture AddGTAOSpatialFilter

Source code excerpt:


	FVector4f FilterWidthParamsValue(0.0f, 0.0f, 0.0f, 0.0f);
	float FilterWidth = CVarGTAOFilterWidth.GetValueOnRenderThread();

	if (FilterWidth == 3.0f)
	{
		FilterWidthParamsValue.X = -1.0f;
		FilterWidthParamsValue.Y = 1.0f;
	}