r.AmbientOcclusion.Method

r.AmbientOcclusion.Method

#Overview

name: r.AmbientOcclusion.Method

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.AmbientOcclusion.Method is to select between different Ambient Occlusion (AO) methods in Unreal Engine’s rendering system. Specifically, it allows developers to choose between Screen Space Ambient Occlusion (SSAO) and Ground Truth Ambient Occlusion (GTAO).

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the composition lighting subsystem for post-processing ambient occlusion effects.

The value of this variable is set through a console variable (CVarAmbientOcclusionMethod) which can be modified at runtime. It defaults to 0 (SSAO) but can be changed to 1 for GTAO.

The associated variable CVarAmbientOcclusionMethod directly interacts with r.AmbientOcclusion.Method, as they share the same value and purpose.

Developers must be aware that changing this variable affects the ambient occlusion technique used in the rendering pipeline. This can impact both visual quality and performance. The choice between SSAO and GTAO may depend on the specific requirements of the project, such as visual fidelity, performance constraints, and target hardware capabilities.

Best practices when using this variable include:

  1. Testing both SSAO and GTAO methods to determine which provides the best balance of visual quality and performance for your specific project.
  2. Considering the target hardware when choosing the method, as GTAO may be more performance-intensive.
  3. Using this in conjunction with other ambient occlusion settings for fine-tuning the effect.
  4. Being aware that changing this setting may require adjustments to other lighting and post-processing settings for optimal results.

Regarding the associated variable CVarAmbientOcclusionMethod:

#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:88

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAmbientOcclusionMethod(
	TEXT("r.AmbientOcclusion.Method"),
	0,
	TEXT("Select between SSAO methods \n ")
	TEXT("0: SSAO (default)\n ")
	TEXT("1: GTAO\n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

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

Scope: file

Source code excerpt:


// Helper function to get what type of method we are using
// EGTAOType::EOff					: This is when r.AmbientOcclusion.Method == 0
// EGTAOType::EAsyncHorizonSearch   : This is when We need GBuffer normals and the hardware Supports Async Compute. The trace pass is on the 
//									  Async Pipe and the Intergrate, Spatial and temporal Filters are on the Gfx pipe after the base pass
// EGTAOType::EAsyncCombinedSpatial	: This is when we use Derived normals from the depth buffer and the hardware Supports Async Compute. 
//									  All passes will be on the async compute pipe
// EGTAOType::ENonAsync				: All passes are are on the graphics pipe. Can use either gbuffer normals or derived depth normals.

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarAmbientOcclusionMethod(
	TEXT("r.AmbientOcclusion.Method"),
	0,
	TEXT("Select between SSAO methods \n ")
	TEXT("0: SSAO (default)\n ")
	TEXT("1: GTAO\n "),
	ECVF_RenderThreadSafe | ECVF_Scalability);

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

Scope (from outer to inner):

file
function     EGTAOType FSSAOHelper::GetGTAOPassType

Source code excerpt:

EGTAOType FSSAOHelper::GetGTAOPassType(const FViewInfo& View, uint32 Levels)
{
	int32 Method		= CVarAmbientOcclusionMethod.GetValueOnRenderThread();
	int32 UseNormals	= CVarGTAOUseNormals.GetValueOnRenderThread();

	if (Method == 1)
	{
		if (IsAmbientOcclusionAsyncCompute(View, Levels))
		{