sg.ShadingQuality.NumLevels

sg.ShadingQuality.NumLevels

#Overview

name: sg.ShadingQuality.NumLevels

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of sg.ShadingQuality.NumLevels is to define the number of quality levels available for shading quality settings in Unreal Engine 5. This variable is part of the engine’s scalability system, which allows developers to adjust various quality settings to optimize performance across different hardware configurations.

This setting variable is primarily used by the Engine module, specifically within the Scalability namespace. It’s an integral part of the engine’s graphics and performance scaling system.

The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted through console commands or configuration files. In the provided code, it’s initialized with a default value of 5, representing five quality levels (0 to 4).

The associated variable CVarShadingQuality_NumLevels directly interacts with sg.ShadingQuality.NumLevels. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable is marked as ECVF_ReadOnly, meaning it should not be changed during runtime. It’s intended to be set at engine initialization or through configuration files.

Best practices for using this variable include:

  1. Ensuring that any custom shading quality settings respect the number of levels defined by this variable.
  2. Using the associated CVarShadingQuality_NumLevels when accessing the value in C++ code.
  3. Considering the impact on performance and visual quality when adjusting shading quality levels.

Regarding the associated variable CVarShadingQuality_NumLevels:

The purpose of CVarShadingQuality_NumLevels is to provide a C++ accessible way to get the number of shading quality levels. It’s used throughout the Scalability namespace to ensure that shading quality settings are properly clamped and scaled.

This variable is used in various functions within the Scalability namespace, such as OnChangeShadingQuality, SetFromSingleQualityLevel, and GetQualityLevelCounts. It’s crucial for maintaining consistency in quality level calculations across different parts of the engine.

The value of CVarShadingQuality_NumLevels is set at the same time as sg.ShadingQuality.NumLevels, through the TAutoConsoleVariable declaration.

Developers should use CVarShadingQuality_NumLevels when working with shading quality levels in C++ code, as it provides a convenient way to access the number of levels without directly referencing the console variable.

Best practices include using CVarShadingQuality_NumLevels->GetInt() to retrieve the current number of shading quality levels, and always clamping shading quality values to be within the range defined by this variable.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarShadingQuality_NumLevels(
	TEXT("sg.ShadingQuality.NumLevels"),
	5,
	TEXT("Number of settings quality levels in sg.ShadingQuality\n")
	TEXT(" default: 5 (0..4)"),
	ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarLandscapeQuality_NumLevels(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarShadingQuality_NumLevels(
	TEXT("sg.ShadingQuality.NumLevels"),
	5,
	TEXT("Number of settings quality levels in sg.ShadingQuality\n")
	TEXT(" default: 5 (0..4)"),
	ECVF_ReadOnly);

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

Scope (from outer to inner):

file
namespace    Scalability
function     void OnChangeShadingQuality

Source code excerpt:

void OnChangeShadingQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("ShadingQuality"), Var->GetInt(), CVarShadingQuality_NumLevels->GetInt());
}

void OnChangeLandscapeQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("LandscapeQuality"), Var->GetInt(), CVarLandscapeQuality_NumLevels->GetInt());
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevel

Source code excerpt:

	EffectsQuality = FMath::Clamp(Value, 0, CVarEffectsQuality_NumLevels->GetInt() - 1);
	FoliageQuality = FMath::Clamp(Value, 0, CVarFoliageQuality_NumLevels->GetInt() - 1);
	ShadingQuality = FMath::Clamp(Value, 0, CVarShadingQuality_NumLevels->GetInt() - 1);
	LandscapeQuality = FMath::Clamp(Value, 0, CVarLandscapeQuality_NumLevels->GetInt() - 1);
}

void FQualityLevels::SetFromSingleQualityLevelRelativeToMax(int32 Value)
{
	ResolutionQuality = GetRenderScaleLevelFromQualityLevel(Value, EQualityLevelBehavior::ERelativeToMax);

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevelRelativeToMax

Source code excerpt:

	EffectsQuality = FMath::Max(CVarEffectsQuality_NumLevels->GetInt() - Value, 0);
	FoliageQuality = FMath::Max(CVarFoliageQuality_NumLevels->GetInt() - Value, 0);
	ShadingQuality = FMath::Max(CVarShadingQuality_NumLevels->GetInt() - Value, 0);
	LandscapeQuality =  FMath::Max(CVarLandscapeQuality_NumLevels->GetInt() - Value, 0);
}

// Returns the overall value if all settings are set to the same thing
// @param Value -1:custom 0:low, 1:medium, 2:high, 3:epic
int32 FQualityLevels::GetSingleQualityLevel() const

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetShadingQuality

Source code excerpt:

void FQualityLevels::SetShadingQuality(int32 Value)
{
	ShadingQuality = FMath::Clamp(Value, 0, CVarShadingQuality_NumLevels->GetInt() - 1);
}

void FQualityLevels::SetLandscapeQuality(int32 Value)
{
	LandscapeQuality = FMath::Clamp(Value, 0, CVarLandscapeQuality_NumLevels->GetInt() - 1);
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     FQualityLevels GetQualityLevelCounts

Source code excerpt:

	Result.EffectsQuality = CVarEffectsQuality_NumLevels->GetInt();
	Result.FoliageQuality = CVarFoliageQuality_NumLevels->GetInt();
	Result.ShadingQuality = CVarShadingQuality_NumLevels->GetInt();
	Result.LandscapeQuality = CVarLandscapeQuality_NumLevels->GetInt();
	return Result;
}

void LoadPlatformScalability(FString PlatformName)
{