r.DefaultFeature.AmbientOcclusion

r.DefaultFeature.AmbientOcclusion

#Overview

name: r.DefaultFeature.AmbientOcclusion

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.DefaultFeature.AmbientOcclusion is to control the default setting for Ambient Occlusion in the Unreal Engine rendering system. It serves as an engine-wide default that can be overridden by post-process volumes, camera settings, or game-specific settings.

This setting variable is primarily used by the rendering system, specifically for post-processing effects. Based on the callsites, it’s clear that the Engine module relies on this variable, particularly in the scene view and post-processing components.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning Ambient Occlusion is enabled by default. The value can be changed at runtime through console commands or programmatically.

The r.DefaultFeature.AmbientOcclusion variable interacts with the AmbientOcclusionIntensity property in the FPostProcessSettings struct. When r.DefaultFeature.AmbientOcclusion is set to 0, it forces AmbientOcclusionIntensity to 0, effectively disabling Ambient Occlusion.

Developers should be aware that this variable sets a default behavior that can be overridden by more specific settings. It’s important to understand the hierarchy of settings in Unreal Engine to ensure the desired Ambient Occlusion behavior is achieved.

Best practices when using this variable include:

  1. Use it to set a project-wide default for Ambient Occlusion.
  2. Be aware that it can be overridden by more specific settings.
  3. Consider performance implications when enabling or disabling Ambient Occlusion globally.

Regarding the associated variable CVarDefaultAmbientOcclusion:

This is the actual console variable that stores and manages the r.DefaultFeature.AmbientOcclusion setting. It’s defined using the TAutoConsoleVariable template, which is part of Unreal Engine’s configuration system.

The purpose of CVarDefaultAmbientOcclusion is to provide a runtime-configurable way to control the default Ambient Occlusion setting. It’s used in the FSceneView::StartFinalPostprocessSettings function to determine whether to apply Ambient Occlusion in the final post-processing stage.

Developers should be aware that changing CVarDefaultAmbientOcclusion at runtime will affect all views that don’t have more specific Ambient Occlusion settings. It’s a powerful tool for debugging or dynamically adjusting rendering features, but should be used cautiously in shipping games to ensure consistent visual quality.

Best practices for CVarDefaultAmbientOcclusion include:

  1. Use it for debugging or performance testing during development.
  2. Be cautious about changing it at runtime in shipping builds.
  3. Consider exposing it as a user-configurable setting if dynamic quality adjustment is desired.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:143

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDefaultAmbientOcclusion(
	TEXT("r.DefaultFeature.AmbientOcclusion"),
	1,
	TEXT("Engine default (project setting) for AmbientOcclusion is (postprocess volume/camera/game setting still can override)\n")
	TEXT(" 0: off, sets AmbientOcclusionIntensity to 0\n")
	TEXT(" 1: on (default)"));

static TAutoConsoleVariable<int32> CVarDefaultAmbientOcclusionStaticFraction(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scene.cpp:536

Scope (from outer to inner):

file
function     FPostProcessSettings::FPostProcessSettings

Source code excerpt:

	FilmGrainTexelSize = 1.0f;

	// next value might get overwritten by r.DefaultFeature.AmbientOcclusion
	AmbientOcclusionIntensity = .5f;
	// next value might get overwritten by r.DefaultFeature.AmbientOcclusionStaticFraction
	AmbientOcclusionStaticFraction = 1.0f;
	AmbientOcclusionRadius = 200.0f;
	AmbientOcclusionDistance_DEPRECATED = 80.0f;
	AmbientOcclusionFadeDistance = 8000.0f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:142

Scope: file

Source code excerpt:

	TEXT(" 1: on (default)"));

static TAutoConsoleVariable<int32> CVarDefaultAmbientOcclusion(
	TEXT("r.DefaultFeature.AmbientOcclusion"),
	1,
	TEXT("Engine default (project setting) for AmbientOcclusion is (postprocess volume/camera/game setting still can override)\n")
	TEXT(" 0: off, sets AmbientOcclusionIntensity to 0\n")
	TEXT(" 1: on (default)"));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:1944

Scope (from outer to inner):

file
function     void FSceneView::StartFinalPostprocessSettings

Source code excerpt:

			FinalPostProcessSettings.BloomIntensity = 0;
		}
		if (!CVarDefaultAmbientOcclusion.GetValueOnGameThread())
		{
			FinalPostProcessSettings.AmbientOcclusionIntensity = 0;
		}
		if (!CVarDefaultAutoExposure.GetValueOnGameThread())
		{
			FinalPostProcessSettings.AutoExposureMinBrightness = 1;