sg.FoliageQuality.NumLevels
sg.FoliageQuality.NumLevels
#Overview
name: sg.FoliageQuality.NumLevels
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of settings quality levels in sg.FoliageQuality\n default: 5 (0..4)
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of sg.FoliageQuality.NumLevels is to define the number of quality levels available for foliage rendering in Unreal Engine 5. This setting variable is part of the scalability system, which allows adjusting graphics quality settings to optimize performance across different hardware configurations.
The Unreal Engine subsystem that relies on this setting variable is the Scalability system, which is part of the Engine module. This can be seen from the file path “Engine/Source/Runtime/Engine/Private/Scalability.cpp” where the variable is defined and used.
The value of this variable is set as a console variable with a default value of 5, meaning there are five quality levels (0 to 4) for foliage rendering by default. The value is set using the TAutoConsoleVariable template class, which allows it to be changed at runtime through console commands.
This variable interacts closely with its associated variable CVarFoliageQuality_NumLevels. They share the same value and are used interchangeably in the code. The CVarFoliageQuality_NumLevels variable is used in various functions within the Scalability namespace to set and adjust foliage quality levels.
Developers must be aware that this variable determines the range of valid values for foliage quality settings. When setting foliage quality, values should be clamped between 0 and (NumLevels - 1) to ensure they are within the valid range.
Best practices when using this variable include:
- Respecting the defined number of levels when setting foliage quality.
- Using the associated CVarFoliageQuality_NumLevels variable in C++ code for consistency.
- Considering the impact on performance when adjusting foliage quality levels.
Regarding the associated variable CVarFoliageQuality_NumLevels:
The purpose of CVarFoliageQuality_NumLevels is to provide a programmatic way to access and use the number of foliage quality levels within the engine’s C++ code. It serves as the implementation detail for the sg.FoliageQuality.NumLevels console variable.
This variable is used in various functions within the Scalability namespace, such as OnChangeFoliageQuality, SetFromSingleQualityLevel, and GetQualityLevelCounts. It’s crucial for ensuring that foliage quality settings are always within the valid range and for dynamically adjusting quality levels based on user input or automatic performance scaling.
The value of CVarFoliageQuality_NumLevels is set when the console variable sg.FoliageQuality.NumLevels is initialized. They share the same value throughout the engine’s execution.
Developers should use CVarFoliageQuality_NumLevels when working with foliage quality levels in C++ code, as it provides a type-safe and efficient way to access the number of quality levels. It’s particularly important to use this variable when clamping foliage quality values or calculating relative quality levels.
Best practices for using CVarFoliageQuality_NumLevels include:
- Always use it to determine the maximum foliage quality level (CVarFoliageQuality_NumLevels->GetInt() - 1).
- Use it in conjunction with FMath::Clamp when setting foliage quality to ensure values are within the valid range.
- Consider it when implementing custom scalability options or performance optimization features that involve foliage rendering.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:171
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarFoliageQuality_NumLevels(
TEXT("sg.FoliageQuality.NumLevels"),
5,
TEXT("Number of settings quality levels in sg.FoliageQuality\n")
TEXT(" default: 5 (0..4)"),
ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarShadingQuality_NumLevels(
#Associated Variable and Callsites
This variable is associated with another variable named CVarFoliageQuality_NumLevels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:170
Scope: file
Source code excerpt:
ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarFoliageQuality_NumLevels(
TEXT("sg.FoliageQuality.NumLevels"),
5,
TEXT("Number of settings quality levels in sg.FoliageQuality\n")
TEXT(" default: 5 (0..4)"),
ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:557
Scope (from outer to inner):
file
namespace Scalability
function void OnChangeFoliageQuality
Source code excerpt:
void OnChangeFoliageQuality(IConsoleVariable* Var)
{
SetGroupQualityLevel(TEXT("FoliageQuality"), Var->GetInt(), CVarFoliageQuality_NumLevels->GetInt());
}
void OnChangeShadingQuality(IConsoleVariable* Var)
{
SetGroupQualityLevel(TEXT("ShadingQuality"), Var->GetInt(), CVarShadingQuality_NumLevels->GetInt());
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:998
Scope (from outer to inner):
file
namespace Scalability
function void FQualityLevels::SetFromSingleQualityLevel
Source code excerpt:
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);
}
void FQualityLevels::SetFromSingleQualityLevelRelativeToMax(int32 Value)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:1018
Scope (from outer to inner):
file
namespace Scalability
function void FQualityLevels::SetFromSingleQualityLevelRelativeToMax
Source code excerpt:
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);
}
// 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
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:1101
Scope (from outer to inner):
file
namespace Scalability
function void FQualityLevels::SetFoliageQuality
Source code excerpt:
void FQualityLevels::SetFoliageQuality(int32 Value)
{
FoliageQuality = FMath::Clamp(Value, 0, CVarFoliageQuality_NumLevels->GetInt() - 1);
}
void FQualityLevels::SetShadingQuality(int32 Value)
{
ShadingQuality = FMath::Clamp(Value, 0, CVarShadingQuality_NumLevels->GetInt() - 1);
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Scalability.cpp:1214
Scope (from outer to inner):
file
namespace Scalability
function FQualityLevels GetQualityLevelCounts
Source code excerpt:
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;
}
void LoadPlatformScalability(FString PlatformName)