r.AmbientOcclusionMaxQuality

r.AmbientOcclusionMaxQuality

#Overview

name: r.AmbientOcclusionMaxQuality

The value of this variable can be defined or overridden in .ini config files. 5 .ini config files referencing this setting variable.

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.AmbientOcclusionMaxQuality is to control the quality level of Screen Space Ambient Occlusion (SSAO) in Unreal Engine’s rendering system. It allows developers to fine-tune the balance between visual quality and performance for ambient occlusion effects.

This setting variable is primarily used by the rendering subsystem, specifically within the post-processing and composition lighting modules of Unreal Engine.

The value of this variable is set through a console variable (CVar) named CVarAmbientOcclusionMaxQuality. It’s initialized with a default value of 100.0f, which means it doesn’t override the quality level set by post-process volumes by default.

The associated variable CVarAmbientOcclusionMaxQuality interacts directly with r.AmbientOcclusionMaxQuality, as they share the same value and purpose.

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

  1. The value range and its effects:

    • 100: Default value, doesn’t override post-process volume settings
    • 0 to 99: Clamps the quality level from post-process volumes to this maximum
    • -100 to 0: Enforces a specific quality level (absolute value) even if post-process volumes request lower quality
  2. It affects performance and visual quality, so careful tuning is necessary.

  3. The variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating it’s used for scalability purposes and is safe to modify on the render thread.

Best practices when using this variable include:

  1. Use it to optimize performance on lower-end hardware by setting a lower maximum quality.
  2. Experiment with different values to find the optimal balance between visual quality and performance for your specific game or application.
  3. Consider exposing this setting to end-users as a graphics option for performance tuning.
  4. Be cautious when using negative values, as they can override artist-defined settings in post-process volumes.

Regarding the associated variable CVarAmbientOcclusionMaxQuality:

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:392, section: [PostProcessQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:412, section: [PostProcessQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:445, section: [PostProcessQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:480, section: [PostProcessQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:517, section: [PostProcessQuality@Cine]

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarAmbientOcclusionMaxQuality(
	TEXT("r.AmbientOcclusionMaxQuality"),
	100.0f,
	TEXT("Defines the max clamping value from the post process volume's quality level for ScreenSpace Ambient Occlusion\n")
	TEXT("     100: don't override quality level from the post process volume (default)\n")
	TEXT("   0..99: clamp down quality level from the post process volume to the maximum set by this cvar\n")
	TEXT(" -100..0: Enforces a different quality (the absolute value) even if the postprocessvolume asks for a lower quality."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarAmbientOcclusionMaxQuality(
	TEXT("r.AmbientOcclusionMaxQuality"),
	100.0f,
	TEXT("Defines the max clamping value from the post process volume's quality level for ScreenSpace Ambient Occlusion\n")
	TEXT("     100: don't override quality level from the post process volume (default)\n")
	TEXT("   0..99: clamp down quality level from the post process volume to the maximum set by this cvar\n")
	TEXT(" -100..0: Enforces a different quality (the absolute value) even if the postprocessvolume asks for a lower quality."),

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

Scope (from outer to inner):

file
function     float FSSAOHelper::GetAmbientOcclusionQualityRT

Source code excerpt:

float FSSAOHelper::GetAmbientOcclusionQualityRT(const FSceneView& View)
{
	float CVarValue = CVarAmbientOcclusionMaxQuality.GetValueOnRenderThread();

	if (CVarValue < 0)
	{
		return FMath::Clamp(-CVarValue, 0.0f, 100.0f);
	}
	else