sg.TextureQuality.NumLevels

sg.TextureQuality.NumLevels

#Overview

name: sg.TextureQuality.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.TextureQuality.NumLevels is to define the number of quality levels available for texture settings in Unreal Engine 5. This variable is part of the scalability system, which allows for adjusting graphics 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 quality management system.

The value of this variable is set as a console variable (CVar) with a default value of 5, meaning there are 5 quality levels (0 to 4) for texture settings by default. This is defined in the Engine/Source/Runtime/Engine/Private/Scalability.cpp file.

The associated variable CVarTextureQuality_NumLevels directly interacts with sg.TextureQuality.NumLevels. They share the same value and purpose.

Developers should be aware that this variable is marked as ECVF_ReadOnly, meaning it’s intended to be set at startup and not changed during runtime. Changing this value would require recompiling the engine or modifying engine initialization code.

Best practices when using this variable include:

  1. Respecting the read-only nature of the variable.
  2. Ensuring that any custom texture quality settings respect the number of levels defined by this variable.
  3. Using the associated functions like SetTextureQuality() to manage texture quality levels within the defined range.

Regarding the associated variable CVarTextureQuality_NumLevels:

It serves the same purpose as sg.TextureQuality.NumLevels, defining the number of texture quality levels available in the engine. This C++ variable is used throughout the Scalability namespace to manage and apply texture quality settings.

CVarTextureQuality_NumLevels is used in several key functions:

  1. OnChangeTextureQuality(): Updates the texture quality when changed.
  2. SetFromSingleQualityLevel(): Sets all quality levels, including texture, based on a single input value.
  3. SetFromSingleQualityLevelRelativeToMax(): Similar to above, but sets quality relative to the maximum level.
  4. SetTextureQuality(): Directly sets the texture quality level.
  5. GetQualityLevelCounts(): Returns the number of levels for each quality setting.

Developers should use these functions when interacting with texture quality settings rather than directly modifying the CVarTextureQuality_NumLevels variable. This ensures proper bounds checking and consistent behavior across the engine.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarEffectsQuality_NumLevels(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

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

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

Scope (from outer to inner):

file
namespace    Scalability
function     void OnChangeTextureQuality

Source code excerpt:

void OnChangeTextureQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("TextureQuality"), Var->GetInt(), CVarTextureQuality_NumLevels->GetInt());
}

void OnChangeEffectsQuality(IConsoleVariable* Var)
{
	SetGroupQualityLevel(TEXT("EffectsQuality"), Var->GetInt(), CVarEffectsQuality_NumLevels->GetInt());
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevel

Source code excerpt:

	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);
	ShadingQuality = FMath::Clamp(Value, 0, CVarShadingQuality_NumLevels->GetInt() - 1);
	LandscapeQuality = FMath::Clamp(Value, 0, CVarLandscapeQuality_NumLevels->GetInt() - 1);
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetFromSingleQualityLevelRelativeToMax

Source code excerpt:

	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);
	ShadingQuality = FMath::Max(CVarShadingQuality_NumLevels->GetInt() - Value, 0);
	LandscapeQuality =  FMath::Max(CVarLandscapeQuality_NumLevels->GetInt() - Value, 0);
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     void FQualityLevels::SetTextureQuality

Source code excerpt:

void FQualityLevels::SetTextureQuality(int32 Value)
{
	TextureQuality = FMath::Clamp(Value, 0, CVarTextureQuality_NumLevels->GetInt() - 1);
}

void FQualityLevels::SetEffectsQuality(int32 Value)
{
	EffectsQuality = FMath::Clamp(Value, 0, CVarEffectsQuality_NumLevels->GetInt() - 1);
}

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

Scope (from outer to inner):

file
namespace    Scalability
function     FQualityLevels GetQualityLevelCounts

Source code excerpt:

	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();
	Result.ShadingQuality = CVarShadingQuality_NumLevels->GetInt();
	Result.LandscapeQuality = CVarLandscapeQuality_NumLevels->GetInt();
	return Result;
}