r.DefaultFeature.AmbientOcclusionStaticFraction

r.DefaultFeature.AmbientOcclusionStaticFraction

#Overview

name: r.DefaultFeature.AmbientOcclusionStaticFraction

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.AmbientOcclusionStaticFraction is to control the default setting for the Ambient Occlusion Static Fraction in Unreal Engine’s rendering system. This variable is part of the post-processing effects, specifically related to ambient occlusion.

This setting variable is primarily used by the rendering system, particularly in the post-processing pipeline. Based on the callsites, it’s clear that the Engine module relies on this variable for setting up the default post-processing settings.

The value of this variable is set through a console variable (CVar) named CVarDefaultAmbientOcclusionStaticFraction. It’s defined in the Engine module, specifically in the SceneView.cpp file.

The r.DefaultFeature.AmbientOcclusionStaticFraction variable interacts with the AmbientOcclusionStaticFraction property of the FPostProcessSettings struct. When the console variable is set to 0, it forces AmbientOcclusionStaticFraction to 0, effectively turning off the static fraction of ambient occlusion.

Developers must be aware that this setting can be overridden by post-process volumes, camera settings, or game-specific settings. It’s meant to provide a default value for the engine, but it’s not the final say in how ambient occlusion is applied.

Best practices when using this variable include:

  1. Use it to set a project-wide default for ambient occlusion static fraction.
  2. Be aware that setting it to 0 will turn off the static fraction of ambient occlusion, which might be desirable for performance reasons in some cases.
  3. Remember that this setting can be overridden, so it should be used in conjunction with other ambient occlusion settings for fine-tuning.

Regarding the associated variable CVarDefaultAmbientOcclusionStaticFraction:

This is a console variable that directly controls the r.DefaultFeature.AmbientOcclusionStaticFraction setting. It’s defined in the Engine module, specifically in SceneView.cpp.

The purpose of this CVar is to provide a way to change the default ambient occlusion static fraction at runtime or through configuration files.

It’s used in the FSceneView::StartFinalPostprocessSettings function to potentially override the AmbientOcclusionStaticFraction in the final post-process settings.

Developers should be aware that changing this CVar will affect the entire project’s default setting for ambient occlusion static fraction. It’s a powerful tool for adjusting the look of the game globally, but should be used carefully.

Best practices for using this CVar include:

  1. Use it for debugging or testing different ambient occlusion settings quickly.
  2. Consider exposing it in development builds for artists to tweak, but probably not in shipping builds.
  3. Remember that a value of 0 turns off the static fraction of ambient occlusion, while 1 enables it (with an extra rendering pass).

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDefaultAmbientOcclusionStaticFraction(
	TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction"),
	1,
	TEXT("Engine default (project setting) for AmbientOcclusion is (postprocess volume/camera/game setting still can override)\n")
	TEXT(" 0: off, sets AmbientOcclusionStaticFraction to 0\n")
	TEXT(" 1: on (default, costs extra pass, only useful if there is some baked lighting)"));

static TAutoConsoleVariable<int32> CVarDefaultAutoExposure(

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

Scope (from outer to inner):

file
function     FPostProcessSettings::FPostProcessSettings

Source code excerpt:

	// 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;
	AmbientOcclusionFadeRadius = 5000.0f;
	AmbientOcclusionPower = 2.0f;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

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

static TAutoConsoleVariable<int32> CVarDefaultAmbientOcclusionStaticFraction(
	TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction"),
	1,
	TEXT("Engine default (project setting) for AmbientOcclusion is (postprocess volume/camera/game setting still can override)\n")
	TEXT(" 0: off, sets AmbientOcclusionStaticFraction to 0\n")
	TEXT(" 1: on (default, costs extra pass, only useful if there is some baked lighting)"));

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

Scope (from outer to inner):

file
function     void FSceneView::StartFinalPostprocessSettings

Source code excerpt:


		{
			int32 Value = CVarDefaultAmbientOcclusionStaticFraction.GetValueOnGameThread();

			if(!Value)
			{
				FinalPostProcessSettings.AmbientOcclusionStaticFraction = 0.0f;
			}
		}