r.ScreenPercentage.Default
r.ScreenPercentage.Default
#Overview
name: r.ScreenPercentage.Default
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ScreenPercentage.Default is to set the default screen percentage for rendering in Unreal Engine 5. This setting is primarily used in the rendering system to control the resolution scaling of the game viewport.
This setting variable is primarily relied upon by the Engine module, specifically within the legacy screen percentage driver system. It’s used to determine the base resolution fraction for rendering when no other overrides are present.
The value of this variable is set as a console variable with a default value of 100.0f, meaning 100% of the native resolution by default. It can be modified at runtime through the console or through game code.
The associated variable CVarScreenPercentageDefault directly interacts with r.ScreenPercentage.Default. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the rendering resolution and, consequently, the performance and visual quality of the game. Lower values will improve performance but reduce visual quality, while higher values will do the opposite.
Best practices when using this variable include:
- Use it as a scalability option, allowing players to adjust their game’s performance vs. quality.
- Consider platform-specific defaults, as mobile devices might benefit from a lower default value.
- Ensure that any dynamic adjustments to this value are smooth to avoid jarring visual changes.
- Be cautious when setting values above 100%, as it can significantly impact performance.
Regarding the associated variable CVarScreenPercentageDefault:
The purpose of CVarScreenPercentageDefault is to provide a programmatic way to access and modify the r.ScreenPercentage.Default value within the C++ code of Unreal Engine.
This variable is used within the Engine module, specifically in the legacy screen percentage driver system. It’s utilized to retrieve the current screen percentage value and apply it to the rendering pipeline.
The value of CVarScreenPercentageDefault is set when r.ScreenPercentage.Default is initialized or modified. It can be accessed using the GetValueOnGameThread() method.
CVarScreenPercentageDefault interacts directly with r.ScreenPercentage.Default, effectively serving as its C++ representation within the engine code.
Developers should be aware that modifying CVarScreenPercentageDefault will have the same effect as changing r.ScreenPercentage.Default. It’s important to use this variable consistently with the console variable to avoid conflicts.
Best practices for using CVarScreenPercentageDefault include:
- Use GetValueOnGameThread() to retrieve the current value in game code.
- Consider caching the value if it’s accessed frequently, as GetValueOnGameThread() may have some overhead.
- When setting the value, ensure it’s within the acceptable range (typically between Scalability::MinResolutionScale and 100.0 or higher).
- Be aware of potential performance implications when modifying this value dynamically during gameplay.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:8
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarScreenPercentageDefault(
TEXT("r.ScreenPercentage.Default"), 100.f,
TEXT(""),
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<int32> CVarScreenPercentageDefaultDesktopMode(
TEXT("r.ScreenPercentage.Default.Desktop.Mode"), int32(EScreenPercentageMode::BasedOnDisplayResolution),
TEXT(""),
#Associated Variable and Callsites
This variable is associated with another variable named CVarScreenPercentageDefault
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:7
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarScreenPercentageDefault(
TEXT("r.ScreenPercentage.Default"), 100.f,
TEXT(""),
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<int32> CVarScreenPercentageDefaultDesktopMode(
TEXT("r.ScreenPercentage.Default.Desktop.Mode"), int32(EScreenPercentageMode::BasedOnDisplayResolution),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LegacyScreenPercentageDriver.cpp:230
Scope (from outer to inner):
file
function void FStaticResolutionFractionHeuristic::FUserSettings::PullRunTimeRenderingSettings
Source code excerpt:
else
{
GlobalResolutionFraction = GetResolutionFraction(FMath::Max(CVarScreenPercentageDefault.GetValueOnGameThread(), Scalability::MinResolutionScale));
if (ViewStatus == EViewStatusForScreenPercentage::PathTracer)
{
Mode = EScreenPercentageMode(FMath::Clamp(CVarScreenPercentageDefaultPathTracerMode.GetValueOnGameThread(), 0, 2));
}
else if (ViewStatus == EViewStatusForScreenPercentage::VR)