au.DisableOcclusion

au.DisableOcclusion

#Overview

name: au.DisableOcclusion

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 au.DisableOcclusion is to control the audio occlusion feature in Unreal Engine 5. It is used to enable or disable the audio occlusion system, which affects how sound propagates through the game environment.

This setting variable is primarily used by the audio system within the Engine module of Unreal Engine 5. Based on the callsites, it’s specifically referenced in the ActiveSound.cpp file, which is part of the core audio processing system.

The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 (enabled) by default, but can be changed at runtime or through configuration files.

The au.DisableOcclusion variable interacts directly with the AudioOcclusionDisabledCvar variable. They share the same value, with AudioOcclusionDisabledCvar being the actual int32 variable used in the code logic.

Developers must be aware that setting this variable to 1 will completely disable audio occlusion, while 0 enables it. This can have a significant impact on the realism and immersion of the game’s audio environment.

Best practices when using this variable include:

  1. Only disable occlusion if absolutely necessary, as it’s an important feature for realistic sound propagation.
  2. Consider exposing this setting to end-users for performance optimization on lower-end systems.
  3. Test thoroughly with both enabled and disabled states to ensure proper audio behavior in all scenarios.

Regarding the associated variable AudioOcclusionDisabledCvar:

The purpose of AudioOcclusionDisabledCvar is to store the actual value of the audio occlusion setting within the engine’s code.

This variable is used directly in the audio processing logic, specifically in the FActiveSound::CheckOcclusion function. It determines whether occlusion checks should be performed for active sounds.

The value of AudioOcclusionDisabledCvar is set through the au.DisableOcclusion console variable.

It interacts primarily with the au.DisableOcclusion CVar, serving as the actual storage for the setting’s value.

Developers should be aware that this variable is used in conditional statements to determine whether occlusion checks should be skipped. When it’s set to 1, occlusion is completely bypassed.

Best practices for AudioOcclusionDisabledCvar include:

  1. Avoid modifying this variable directly; instead, use the au.DisableOcclusion CVar to change its value.
  2. Be cautious when optimizing code paths that depend on this variable, as changes may affect audio behavior engine-wide.
  3. Consider adding debug logging around usage of this variable to track when and where occlusion is being disabled during development.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActiveSound.cpp:16

Scope: file

Source code excerpt:

static int32 AudioOcclusionDisabledCvar = 0;
FAutoConsoleVariableRef CVarAudioOcclusionEnabled(
	TEXT("au.DisableOcclusion"),
	AudioOcclusionDisabledCvar,
	TEXT("Disables (1) or enables (0) audio occlusion.\n"),
	ECVF_Default);

static int32 GatherInteriorDataFromAudioVolumesCVar = 1;
FAutoConsoleVariableRef CVarGatherInteriorDataFromAudioVolumes(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActiveSound.cpp:14

Scope: file

Source code excerpt:



static int32 AudioOcclusionDisabledCvar = 0;
FAutoConsoleVariableRef CVarAudioOcclusionEnabled(
	TEXT("au.DisableOcclusion"),
	AudioOcclusionDisabledCvar,
	TEXT("Disables (1) or enables (0) audio occlusion.\n"),
	ECVF_Default);

static int32 GatherInteriorDataFromAudioVolumesCVar = 1;
FAutoConsoleVariableRef CVarGatherInteriorDataFromAudioVolumes(
	TEXT("au.InteriorData.UseAudioVolumes"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActiveSound.cpp:1225

Scope (from outer to inner):

file
function     void FActiveSound::CheckOcclusion

Source code excerpt:


	// If occlusion is disabled by cvar, we're always going to be not occluded
	if (AudioOcclusionDisabledCvar == 1)
	{
		bIsOccluded = false;
	}
	else
	{
		if (!bAsyncOcclusionPending && (PlaybackTime - LastOcclusionCheckTime) > OcclusionCheckInterval)