r.GTAO.SpatialFilter

r.GTAO.SpatialFilter

#Overview

name: r.GTAO.SpatialFilter

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.GTAO.SpatialFilter is to enable or disable the Spatial Filter for Ground Truth Ambient Occlusion (GTAO) in Unreal Engine’s rendering system. This setting is part of the composition lighting subsystem, which is responsible for enhancing the visual quality of ambient occlusion in the rendered scene.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically within the composition lighting component. This can be seen from the file path where the variable is defined: “Engine/Source/Runtime/Renderer/Private/CompositionLighting/CompositionLighting.cpp”.

The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 1 (enabled) and can be changed at runtime through the console or configuration files.

This variable interacts closely with another variable named CVarGTAOSpatialFilter, which is the actual console variable instance. They share the same value and purpose.

Developers must be aware that this variable is render thread safe and affects scalability. It can be toggled between 0 (off) and 1 (on) to enable or disable the GTAO Spatial Filter. The setting directly impacts the visual quality and performance of ambient occlusion in the scene.

Best practices when using this variable include:

  1. Consider performance implications when enabling the spatial filter, as it may have an impact on rendering time.
  2. Use it in conjunction with other GTAO settings for optimal results.
  3. Test the visual impact and performance with both enabled and disabled states to find the best balance for your project.

Regarding the associated variable CVarGTAOSpatialFilter:

The purpose of CVarGTAOSpatialFilter is to provide a console-accessible way to control the r.GTAO.SpatialFilter setting. It is the actual variable that stores the current state of the GTAO Spatial Filter setting.

This variable is used within the Renderer module to determine whether to apply the spatial filter in various GTAO-related functions. It is accessed using GetValueOnRenderThread() to ensure thread-safe operations.

The value of CVarGTAOSpatialFilter is set through the console variable system and can be changed at runtime.

It interacts directly with the r.GTAO.SpatialFilter setting and is used in conjunction with other GTAO-related variables like CVarGTAOTemporalFilter.

Developers should be aware that this variable’s value is checked on the render thread, which ensures that changes are applied correctly within the rendering pipeline.

Best practices for using CVarGTAOSpatialFilter include:

  1. Use GetValueOnRenderThread() when accessing the value to ensure thread safety.
  2. Consider caching the value if it’s accessed frequently to avoid potential performance overhead from repeated console variable lookups.
  3. Use it in combination with other GTAO settings for a comprehensive control over the ambient occlusion quality and performance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarGTAOSpatialFilter(
	TEXT("r.GTAO.SpatialFilter"),
	1,
	TEXT("Enable Spatial Filter for GTAO \n ")
	TEXT("0: Off \n ")
	TEXT("1: On (default)\n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarGTAOSpatialFilter(
	TEXT("r.GTAO.SpatialFilter"),
	1,
	TEXT("Enable Spatial Filter for GTAO \n ")
	TEXT("0: Off \n ")
	TEXT("1: On (default)\n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

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

Scope (from outer to inner):

file
function     static FGTAOHorizonSearchOutputs AddPostProcessingGTAOAsyncPasses

Source code excerpt:

	check(CommonParameters.GTAOType == EGTAOType::EAsyncHorizonSearch || CommonParameters.GTAOType == EGTAOType::EAsyncCombinedSpatial);

	const bool bSpatialPass = (CVarGTAOSpatialFilter.GetValueOnRenderThread() == 1);

	FGTAOHorizonSearchOutputs HorizonSearchOutputs;

	if (CommonParameters.GTAOType == EGTAOType::EAsyncHorizonSearch)
	{
		HorizonSearchOutputs =

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

Scope (from outer to inner):

file
function     static FScreenPassTexture AddPostProcessingGTAOAllPasses

Source code excerpt:

	FSceneViewState* ViewState = View.ViewState;

	const bool bSpatialPass = (CVarGTAOSpatialFilter.GetValueOnRenderThread() == 1);
	const bool bTemporalPass = (ViewState && CVarGTAOTemporalFilter.GetValueOnRenderThread() == 1);

	{
		FGTAOHorizonSearchOutputs HorizonSearchOutputs =
			AddGTAOHorizonSearchIntegratePass(
				GraphBuilder,

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

Scope (from outer to inner):

file
function     static FScreenPassTexture AddPostProcessingGTAOPostAsync

Source code excerpt:

	FSceneViewState* ViewState = View.ViewState;

	const bool bSpatialPass = (CVarGTAOSpatialFilter.GetValueOnRenderThread() == 1);
	const bool bTemporalPass = (ViewState && CVarGTAOTemporalFilter.GetValueOnRenderThread() == 1);

	{
		FScreenPassTexture CurrentOutput;

		if (CommonParameters.GTAOType == EGTAOType::EAsyncHorizonSearch)