sg.FoliageQuality

sg.FoliageQuality

#Overview

name: sg.FoliageQuality

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

This variable is created as a Console Variable (cvar).

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of sg.FoliageQuality is to control the quality level of foliage rendering in Unreal Engine 5. This setting is part of the scalability system, which allows adjusting graphics quality to optimize performance across different hardware configurations.

The Unreal Engine subsystems that rely on this setting variable are primarily the rendering system and the scalability system. It’s used in the Engine module and the MovieRenderPipeline plugin.

The value of this variable is set through several methods:

  1. It’s initialized with a default value of 3 (epic quality) in the engine’s source code.
  2. It can be loaded from configuration files using the Scalability::LoadState function.
  3. It can be set programmatically, such as in the MovieRenderPipeline plugin for high-quality rendering.
  4. It can be changed through console commands or the scalability system’s user interface.

This variable interacts with other scalability settings like TextureQuality, EffectsQuality, ShadingQuality, and LandscapeQuality. They are often set together to provide a consistent level of graphical quality.

Developers should be aware that:

  1. Changes to this variable can affect performance and visual quality.
  2. It’s part of the scalability group, meaning it can be adjusted automatically based on performance targets.
  3. The value ranges from 0 (low) to 4 (cinematic), with 3 being the default “epic” quality.

Best practices when using this variable include:

  1. Consider the target hardware when setting this value.
  2. Test performance impact when changing this setting.
  3. Use in conjunction with other scalability settings for a balanced approach to performance optimization.

Regarding the associated variable CVarFoliageQuality: This is the actual console variable that stores the FoliageQuality value. It’s initialized with the same default value and description as sg.FoliageQuality. The CVarFoliageQuality variable is used internally by the engine to access and modify the foliage quality setting. It has an OnChangedCallback set up to trigger appropriate updates when the value changes.

When working with foliage quality, developers can interact with either sg.FoliageQuality or CVarFoliageQuality, as they are essentially two interfaces to the same underlying setting. The sg.FoliageQuality is typically used in configuration files and command-line arguments, while CVarFoliageQuality is used in C++ code for direct access and modification of the setting.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:313, section: [IOS DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:837, section: [Android_Low DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:852, section: [Android_Mid DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:866, section: [Android_High DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:891, section: [Android_Vulkan_SM5 DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:47, section: [Mobile DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:94, section: [IOS_Low DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:107, section: [IOS_Mid DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:134, section: [IOS_High DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:151, section: [IOS_Epic DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:507, section: [Android_Low DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:520, section: [Android_Mid DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:547, section: [Android_High DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:563, section: [Android_Epic DeviceProfile]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:94

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarFoliageQuality(
	TEXT("sg.FoliageQuality"),
	3,
	TEXT("Scalability quality state (internally used by scalability system, ini load/save or using SCALABILITY console command)\n")
	TEXT(" 0:low, 1:med, 2:high, 3:epic, 4:cinematic, default: 3"),
	ECVF_ScalabilityGroup | ECVF_Preview);

static TAutoConsoleVariable<int32> CVarShadingQuality(

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/Graph/Nodes/MovieGraphGlobalGameOverrides.cpp:38

Scope (from outer to inner):

file
function     void UMovieGraphGlobalGameOverridesNode::BuildNewProcessCommandLineArgsImpl

Source code excerpt:

		InOutDeviceProfileCvars.Add(FString::Format(TEXT("sg.TextureQuality={0}"), {QualityLevels.TextureQuality}));
		InOutDeviceProfileCvars.Add(FString::Format(TEXT("sg.EffectsQuality={0}"), {QualityLevels.EffectsQuality}));
		InOutDeviceProfileCvars.Add(FString::Format(TEXT("sg.FoliageQuality={0}"), {QualityLevels.FoliageQuality}));
		InOutDeviceProfileCvars.Add(FString::Format(TEXT("sg.ShadingQuality={0}"), {QualityLevels.ShadingQuality}));
		InOutDeviceProfileCvars.Add(FString::Format(TEXT("sg.LandscapeQuality={0}"), {QualityLevels.LandscapeQuality}));
	}

	if (bDisableTextureStreaming)
	{

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineGameOverrideSetting.cpp:170

Scope (from outer to inner):

file
function     void UMoviePipelineGameOverrideSetting::BuildNewProcessCommandLineArgsImpl

Source code excerpt:

		InOutDeviceProfileCvars.Add(TEXT("sg.TextureQuality=4"));
		InOutDeviceProfileCvars.Add(TEXT("sg.EffectsQuality=4"));
		InOutDeviceProfileCvars.Add(TEXT("sg.FoliageQuality=4"));
		InOutDeviceProfileCvars.Add(TEXT("sg.ShadingQuality=4"));
	}

	switch (TextureStreaming)
	{
	case EMoviePipelineTextureStreamingMethod::FullyLoad:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:1136

Scope (from outer to inner):

file
namespace    Scalability
function     void LoadState

Source code excerpt:

	GConfig->GetInt(Section, TEXT("sg.TextureQuality"), State.TextureQuality, IniName);
	GConfig->GetInt(Section, TEXT("sg.EffectsQuality"), State.EffectsQuality, IniName);
	GConfig->GetInt(Section, TEXT("sg.FoliageQuality"), State.FoliageQuality, IniName);
	GConfig->GetInt(Section, TEXT("sg.ShadingQuality"), State.ShadingQuality, IniName);
	GConfig->GetInt(Section, TEXT("sg.LandscapeQuality"), State.LandscapeQuality, IniName);

	// If possible apply immediately, else store in backup so we can re-apply later
	if (!GScalabilityUsingTemporaryQualityLevels)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:1170

Scope (from outer to inner):

file
namespace    Scalability
function     void SaveState

Source code excerpt:

	GConfig->SetInt(Section, TEXT("sg.TextureQuality"), State.TextureQuality, IniName);
	GConfig->SetInt(Section, TEXT("sg.EffectsQuality"), State.EffectsQuality, IniName);
	GConfig->SetInt(Section, TEXT("sg.FoliageQuality"), State.FoliageQuality, IniName);
	GConfig->SetInt(Section, TEXT("sg.ShadingQuality"), State.ShadingQuality, IniName);
	GConfig->SetInt(Section, TEXT("sg.LandscapeQuality"), State.LandscapeQuality, IniName);
}

void RecordQualityLevelsAnalytics(bool bAutoApplied)
{

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Settings/LyraSettingsLocal.cpp:276

Scope (from outer to inner):

file
namespace    LyraSettingsHelpers
function     void FillScalabilitySettingsFromDeviceProfile

Source code excerpt:

		Mode.bHasOverrides |= UDeviceProfileManager::GetScalabilityCVar(FString::Printf(TEXT("sg.TextureQuality%s"), *Suffix), Mode.Qualities.TextureQuality);
		Mode.bHasOverrides |= UDeviceProfileManager::GetScalabilityCVar(FString::Printf(TEXT("sg.EffectsQuality%s"), *Suffix), Mode.Qualities.EffectsQuality);
		Mode.bHasOverrides |= UDeviceProfileManager::GetScalabilityCVar(FString::Printf(TEXT("sg.FoliageQuality%s"), *Suffix), Mode.Qualities.FoliageQuality);
		Mode.bHasOverrides |= UDeviceProfileManager::GetScalabilityCVar(FString::Printf(TEXT("sg.ShadingQuality%s"), *Suffix), Mode.Qualities.ShadingQuality);
	}

	TMobileQualityWrapper<int32> OverallQualityLimits(-1, CVarMobileQualityLimits);
	TMobileQualityWrapper<float> ResolutionQualityLimits(100.0f, CVarMobileResolutionQualityLimits);
	TMobileQualityWrapper<float> ResolutionQualityRecommendations(75.0f, CVarMobileResolutionQualityRecommendation);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:93

Scope: file

Source code excerpt:

	ECVF_ScalabilityGroup | ECVF_Preview);

static TAutoConsoleVariable<int32> CVarFoliageQuality(
	TEXT("sg.FoliageQuality"),
	3,
	TEXT("Scalability quality state (internally used by scalability system, ini load/save or using SCALABILITY console command)\n")
	TEXT(" 0:low, 1:med, 2:high, 3:epic, 4:cinematic, default: 3"),
	ECVF_ScalabilityGroup | ECVF_Preview);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:593

Scope (from outer to inner):

file
namespace    Scalability
function     void InitScalabilitySystem

Source code excerpt:

	CVarTextureQuality.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&OnChangeTextureQuality));
	CVarEffectsQuality.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&OnChangeEffectsQuality));
	CVarFoliageQuality.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&OnChangeFoliageQuality));
	CVarShadingQuality.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&OnChangeShadingQuality));
	CVarLandscapeQuality.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&OnChangeLandscapeQuality));

#if WITH_EDITOR
	ScalabilityShaderPlatform = GMaxRHIShaderPlatform;
	bScalabilityShaderPlatformHasBeenChanged = false;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:895

Scope (from outer to inner):

file
namespace    Scalability
function     void SetQualityLevels

Source code excerpt:

		SetQualityLevelCVar(CVarTextureQuality, ClampedLevels.TextureQuality, GScalabilityQualityLevelsOverride.TextureQuality, bForce);
		SetQualityLevelCVar(CVarEffectsQuality, ClampedLevels.EffectsQuality, GScalabilityQualityLevelsOverride.EffectsQuality, bForce);
		SetQualityLevelCVar(CVarFoliageQuality, ClampedLevels.FoliageQuality, GScalabilityQualityLevelsOverride.FoliageQuality, bForce);
		SetQualityLevelCVar(CVarShadingQuality, ClampedLevels.ShadingQuality, GScalabilityQualityLevelsOverride.ShadingQuality, bForce);
		SetQualityLevelCVar(CVarLandscapeQuality, ClampedLevels.LandscapeQuality, GScalabilityQualityLevelsOverride.LandscapeQuality, bForce);

		OnScalabilitySettingsChanged.Broadcast(ClampedLevels);
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:927

Scope (from outer to inner):

file
namespace    Scalability
function     FQualityLevels GetQualityLevels

Source code excerpt:

		Ret.TextureQuality = CVarTextureQuality.GetValueOnGameThread();
		Ret.EffectsQuality = CVarEffectsQuality.GetValueOnGameThread();
		Ret.FoliageQuality = CVarFoliageQuality.GetValueOnGameThread();
		Ret.ShadingQuality = CVarShadingQuality.GetValueOnGameThread();
		Ret.LandscapeQuality = CVarLandscapeQuality.GetValueOnGameThread();
	}
	else
	{
		Ret = GScalabilityBackupQualityLevels;