r.AmbientOcclusionMipLevelFactor

r.AmbientOcclusionMipLevelFactor

#Overview

name: r.AmbientOcclusionMipLevelFactor

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.AmbientOcclusionMipLevelFactor is to control the mipmap level selection for Screen Space Ambient Occlusion (SSAO) calculations in the rendering system of Unreal Engine 5.

This setting variable is primarily used by the rendering subsystem, specifically in the post-processing pipeline for ambient occlusion calculations. It’s part of the CompositionLighting module within the Renderer.

The value of this variable is set through the console variable system, with a default value of 0.5. It can be adjusted at runtime using console commands or through game settings.

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

Developers must be aware that this variable affects the quality and performance trade-off of the SSAO effect. A value of 0 will always use the highest resolution mipmap (mip level 0), which may cause memory cache trashing. A value of 1 will use higher mipmap levels, resulting in potential quality loss but better performance.

Best practices when using this variable include:

  1. Keeping the default value (0.5) for a balanced approach between quality and performance.
  2. Adjusting it based on the specific needs of the project, considering the target hardware capabilities.
  3. Testing different values to find the optimal balance between visual quality and performance for your specific use case.

Regarding the associated variable CVarAmbientOcclusionStepMipLevelFactor:

The purpose of CVarAmbientOcclusionStepMipLevelFactor is the same as r.AmbientOcclusionMipLevelFactor, as they are directly linked.

It is used in the rendering subsystem, specifically in the PostProcessAmbientOcclusion module of the Renderer.

The value is set through the TAutoConsoleVariable template, which creates a console variable that can be adjusted at runtime.

This variable interacts directly with r.AmbientOcclusionMipLevelFactor, as they share the same value.

Developers should be aware that this is the actual variable used in the code to retrieve the mip level factor value, as seen in the GetAmbientOcclusionStepMipLevelFactor() function.

Best practices for using this variable include:

  1. Using the GetValueOnRenderThread() method to access its value in render thread operations.
  2. Being cautious when modifying its value, as it directly affects the SSAO calculation and can impact both visual quality and performance.
  3. Considering the scalability and render thread safety flags (ECVF_Scalability | ECVF_RenderThreadSafe) when working with this variable in different contexts.

#Setting Variables

#References In INI files

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

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

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

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

Location: <Workspace>/Engine/Config/BaseScalability.ini:516, 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:49

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarAmbientOcclusionStepMipLevelFactor(
	TEXT("r.AmbientOcclusionMipLevelFactor"),
	0.5f,
	TEXT("Controls mipmap level according to the SSAO step id\n")
	TEXT(" 0: always look into the HZB mipmap level 0 (memory cache trashing)\n")
	TEXT(" 0.5: sample count depends on post process settings (default)\n")
	TEXT(" 1: Go into higher mipmap level (quality loss)"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarAmbientOcclusionStepMipLevelFactor(
	TEXT("r.AmbientOcclusionMipLevelFactor"),
	0.5f,
	TEXT("Controls mipmap level according to the SSAO step id\n")
	TEXT(" 0: always look into the HZB mipmap level 0 (memory cache trashing)\n")
	TEXT(" 0.5: sample count depends on post process settings (default)\n")
	TEXT(" 1: Go into higher mipmap level (quality loss)"),

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

Scope (from outer to inner):

file
function     float FSSAOHelper::GetAmbientOcclusionStepMipLevelFactor

Source code excerpt:

float FSSAOHelper::GetAmbientOcclusionStepMipLevelFactor()
{
	return CVarAmbientOcclusionStepMipLevelFactor.GetValueOnRenderThread();
}

EAsyncComputeBudget FSSAOHelper::GetAmbientOcclusionAsyncComputeBudget()
{
	int32 RawBudget = CVarAmbientOcclusionAsyncComputeBudget.GetValueOnRenderThread();