sg.ShadowQuality.NumLevels

sg.ShadowQuality.NumLevels

#Overview

name: sg.ShadowQuality.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.ShadowQuality.NumLevels is to define the number of quality levels available for shadow rendering in Unreal Engine 5. This setting variable is part of the engine’s scalability system, which allows for adjusting various graphical settings to optimize performance across different hardware configurations.

This setting variable is primarily used by the Scalability subsystem within the Engine module. It’s referenced in the Scalability.cpp file, which is responsible for managing the quality levels of various graphical features.

The value of this variable is set as a console variable (CVar) with a default value of 5, representing 5 quality levels (0 to 4) for shadow quality. It’s defined as read-only, meaning it can’t be changed at runtime.

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

Developers should be aware that this variable defines the upper limit for shadow quality settings. When setting or adjusting shadow quality levels in the engine or game code, values should always be clamped between 0 and (CVarShadowQuality_NumLevels->GetInt() - 1) to ensure they fall within the valid range.

Best practices when using this variable include:

  1. Always use the associated CVarShadowQuality_NumLevels when referencing the number of shadow quality levels in code.
  2. When setting shadow quality, use the FMath::Clamp function to ensure the value is within the valid range.
  3. Be aware that changing this value might require adjustments in other parts of the engine or game code that rely on specific shadow quality levels.

Regarding the associated variable CVarShadowQuality_NumLevels:

The purpose of CVarShadowQuality_NumLevels is to provide a programmatic way to access the number of shadow quality levels within the engine’s C++ code. It’s used in various functions within the Scalability namespace to set and manage shadow quality settings.

This variable is used in functions like OnChangeShadowQuality, SetFromSingleQualityLevel, SetFromSingleQualityLevelRelativeToMax, SetShadowQuality, and GetQualityLevelCounts. These functions are responsible for adjusting and retrieving shadow quality settings based on user input or system requirements.

The value of CVarShadowQuality_NumLevels is set when the console variable sg.ShadowQuality.NumLevels is initialized.

Developers should use CVarShadowQuality_NumLevels->GetInt() to retrieve the current number of shadow quality levels in their code. This ensures that any changes to the number of quality levels are automatically reflected throughout the engine.

Best practices for using CVarShadowQuality_NumLevels include:

  1. Always use GetInt() to retrieve its value, as it’s defined as an integer.
  2. Be aware that this value is read-only and cannot be changed at runtime.
  3. Use this variable when implementing custom scalability features or when working with shadow quality settings to ensure consistency with the engine’s built-in scalability system.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarGlobalIlluminationQuality_NumLevels(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

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

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

Scope (from outer to inner):

file
namespace    Scalability
function     void OnChangeShadowQuality

Source code excerpt:

void OnChangeShadowQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("ShadowQuality"), Var->GetInt(), CVarShadowQuality_NumLevels->GetInt());
}

void OnChangeGlobalIlluminationQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("GlobalIlluminationQuality"), Var->GetInt(), CVarGlobalIlluminationQuality_NumLevels->GetInt());
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevel

Source code excerpt:

	ViewDistanceQuality = FMath::Clamp(Value, 0, CVarViewDistanceQuality_NumLevels->GetInt() - 1);
	AntiAliasingQuality = FMath::Clamp(Value, 0, CVarAntiAliasingQuality_NumLevels->GetInt() - 1);
	ShadowQuality = FMath::Clamp(Value, 0, CVarShadowQuality_NumLevels->GetInt() - 1);
	GlobalIlluminationQuality = FMath::Clamp(Value, 0, CVarGlobalIlluminationQuality_NumLevels->GetInt() - 1);
	ReflectionQuality = FMath::Clamp(Value, 0, CVarReflectionQuality_NumLevels->GetInt() - 1);
	PostProcessQuality = FMath::Clamp(Value, 0, CVarPostProcessQuality_NumLevels->GetInt() - 1);
	TextureQuality = FMath::Clamp(Value, 0, CVarTextureQuality_NumLevels->GetInt() - 1);
	EffectsQuality = FMath::Clamp(Value, 0, CVarEffectsQuality_NumLevels->GetInt() - 1);
	FoliageQuality = FMath::Clamp(Value, 0, CVarFoliageQuality_NumLevels->GetInt() - 1);

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevelRelativeToMax

Source code excerpt:

	ViewDistanceQuality = FMath::Max(CVarViewDistanceQuality_NumLevels->GetInt() - Value, 0);
	AntiAliasingQuality = FMath::Max(CVarAntiAliasingQuality_NumLevels->GetInt() - Value, 0);
	ShadowQuality = FMath::Max(CVarShadowQuality_NumLevels->GetInt() - Value, 0);
	GlobalIlluminationQuality = FMath::Max(CVarGlobalIlluminationQuality_NumLevels->GetInt() - Value, 0);
	ReflectionQuality = FMath::Max(CVarReflectionQuality_NumLevels->GetInt() - Value, 0);
	PostProcessQuality = FMath::Max(CVarPostProcessQuality_NumLevels->GetInt() - Value, 0);
	TextureQuality = FMath::Max(CVarTextureQuality_NumLevels->GetInt() - Value, 0);
	EffectsQuality = FMath::Max(CVarEffectsQuality_NumLevels->GetInt() - Value, 0);
	FoliageQuality = FMath::Max(CVarFoliageQuality_NumLevels->GetInt() - Value, 0);

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetShadowQuality

Source code excerpt:

void FQualityLevels::SetShadowQuality(int32 Value)
{
	ShadowQuality = FMath::Clamp(Value, 0, CVarShadowQuality_NumLevels->GetInt() - 1);
}

void FQualityLevels::SetGlobalIlluminationQuality(int32 Value)
{
	GlobalIlluminationQuality = FMath::Clamp(Value, 0, CVarGlobalIlluminationQuality_NumLevels->GetInt() - 1);
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     FQualityLevels GetQualityLevelCounts

Source code excerpt:

	Result.ViewDistanceQuality = CVarViewDistanceQuality_NumLevels->GetInt();
	Result.AntiAliasingQuality = CVarAntiAliasingQuality_NumLevels->GetInt();
	Result.ShadowQuality = CVarShadowQuality_NumLevels->GetInt();
	Result.GlobalIlluminationQuality = CVarGlobalIlluminationQuality_NumLevels->GetInt();
	Result.ReflectionQuality = CVarReflectionQuality_NumLevels->GetInt();
	Result.PostProcessQuality = CVarPostProcessQuality_NumLevels->GetInt();
	Result.TextureQuality = CVarTextureQuality_NumLevels->GetInt();
	Result.EffectsQuality = CVarEffectsQuality_NumLevels->GetInt();
	Result.FoliageQuality = CVarFoliageQuality_NumLevels->GetInt();