r.Editor.Viewport.HighDPI

r.Editor.Viewport.HighDPI

#Overview

name: r.Editor.Viewport.HighDPI

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

It is referenced in 11 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Editor.Viewport.HighDPI is to control whether editor and PIE (Play In Editor) viewports can be displayed at high DPI (Dots Per Inch) resolutions. This setting is primarily used for the rendering system, specifically for managing viewport resolution and display quality in the Unreal Engine editor.

The Unreal Engine subsystems that rely on this setting variable include:

  1. Editor subsystem, particularly the viewport rendering
  2. Play In Editor (PIE) functionality
  3. The engine’s DPI scaling system

The value of this variable is set in several places:

  1. It is initially defined as a console variable with a default value of 1 (enabled) in EditorPerformanceSettings.cpp.
  2. It can be modified through the editor’s project settings, specifically in the EditorPerformanceSettings class.
  3. It can be changed at runtime through the console or configuration files.

This variable interacts with other variables and settings:

  1. It is associated with CVarEditorViewportHighDPI, which shares the same value.
  2. It interacts with bDisplayHighDPIViewports in the EditorPerformanceSettings class.
  3. It affects the behavior of GetDPIDerivedResolutionFraction() in the engine’s client code.

Developers should be aware of the following when using this variable:

  1. Changing this setting can affect the visual quality and performance of editor viewports.
  2. It may impact the accuracy of what developers see in the editor compared to the final build, especially regarding UI scaling and rendering quality.

Best practices when using this variable include:

  1. Consider the target platforms and their typical display resolutions when deciding whether to enable or disable high DPI viewports.
  2. Test the game both with high DPI enabled and disabled to ensure consistent visuals across different display configurations.
  3. Be aware of the performance impact of enabling high DPI, especially on lower-end development machines.

Regarding the associated variable CVarEditorViewportHighDPI:

The purpose of CVarEditorViewportHighDPI is to provide a console-accessible way to control the same high DPI setting as r.Editor.Viewport.HighDPI. It is used internally by the engine to store and retrieve the current high DPI setting value.

This variable is part of the editor’s performance settings and is typically set automatically based on the bDisplayHighDPIViewports property in the EditorPerformanceSettings class. It can be accessed and modified through the console, allowing for runtime changes to the high DPI behavior.

Developers should be aware that changes to CVarEditorViewportHighDPI will directly affect the editor’s viewport rendering behavior. It’s generally recommended to modify this setting through the project settings interface rather than directly through the console, to ensure consistent behavior across editor sessions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:4

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarEditorViewportHighDPI(
	TEXT("r.Editor.Viewport.HighDPI"), 1,
	TEXT("Controls whether editor & PIE viewports can be displayed at high DPI."),
	ECVF_Default);

TAutoConsoleVariable<int32> CVarEditorViewportOverrideGameScreenPercentage(
	TEXT("r.Editor.Viewport.OverridePIEScreenPercentage"), 1,
	TEXT("Apply editor viewports' default screen percentage settings to game viewport clients in PIE."),

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Editor/EditorPerformanceSettings.h:67

Scope (from outer to inner):

file
class        class UEditorPerformanceSettings : public UDeveloperSettings

Source code excerpt:

	UPROPERTY(EditAnywhere, config, Category=ViewportResolution, meta=(
		DisplayName="Displays viewports' at high DPI",
		ConsoleVariable="r.Editor.Viewport.HighDPI"))
	uint32 bDisplayHighDPIViewports : 1;
	
	UPROPERTY(EditAnywhere, config, Category=ViewportResolution, meta=(
		DisplayName="Override project's default screen percentage settings with editor viewports' settings in PIE",
		ConsoleVariable="r.Editor.Viewport.OverridePIEScreenPercentage"))
	uint32 bOverridePIEScreenPercentage : 1;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:109

Scope (from outer to inner):

file
function     static bool GetDefaultLowDPIPreviewValue

Source code excerpt:

static bool GetDefaultLowDPIPreviewValue()
{
	static auto CVarEditorViewportHighDPIPtr = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.HighDPI"));
	return CVarEditorViewportHighDPIPtr->GetInt() == 0;
}

float ComputeOrthoZoomFactor(const float ViewportWidth)
{
	float Ret = 1.0f;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/EditorViewportClient.h:2064

Scope: file

Source code excerpt:

	enum class ESceneDPIMode
	{
		// Uses r.Editor.Viewport.HighDPI.
		EditorDefault,

		// Force emulating low DPI.
		EmulateLowDPI,

		// Force using high dpi.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealClient.cpp:2518

Scope (from outer to inner):

file
function     float FCommonViewportClient::GetDPIDerivedResolutionFraction

Source code excerpt:

		}

		static auto CVarEditorViewportHighDPIPtr = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Editor.Viewport.HighDPI"));

		if (CVarEditorViewportHighDPIPtr && CVarEditorViewportHighDPIPtr->GetInt() == 0)
		{
			return FMath::Min(1.0f / GetDPIScale(), 1.0f);
		}
	}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:3

Scope: file

Source code excerpt:

#include "Settings/EditorProjectSettings.h"

TAutoConsoleVariable<int32> CVarEditorViewportHighDPI(
	TEXT("r.Editor.Viewport.HighDPI"), 1,
	TEXT("Controls whether editor & PIE viewports can be displayed at high DPI."),
	ECVF_Default);

TAutoConsoleVariable<int32> CVarEditorViewportOverrideGameScreenPercentage(
	TEXT("r.Editor.Viewport.OverridePIEScreenPercentage"), 1,

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:41

Scope (from outer to inner):

file
function     void UEditorPerformanceSettings::PostInitProperties

Source code excerpt:

	Super::PostInitProperties();

	CVarEditorViewportHighDPI->Set(bDisplayHighDPIViewports != 0, ECVF_SetByProjectSetting);
	CVarEditorViewportOverrideGameScreenPercentage->Set(bOverridePIEScreenPercentage != 0, ECVF_SetByProjectSetting);

	if (FProperty* EnableVSyncProperty = GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, bEnableVSync)))
	{
		ExportValuesToConsoleVariables(EnableVSyncProperty);
	}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Editor/EditorPerformanceSettings.h:68

Scope (from outer to inner):

file
class        class UEditorPerformanceSettings : public UDeveloperSettings

Source code excerpt:

		DisplayName="Displays viewports' at high DPI",
		ConsoleVariable="r.Editor.Viewport.HighDPI"))
	uint32 bDisplayHighDPIViewports : 1;
	
	UPROPERTY(EditAnywhere, config, Category=ViewportResolution, meta=(
		DisplayName="Override project's default screen percentage settings with editor viewports' settings in PIE",
		ConsoleVariable="r.Editor.Viewport.OverridePIEScreenPercentage"))
	uint32 bOverridePIEScreenPercentage : 1;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:20

Scope (from outer to inner):

file
function     UEditorPerformanceSettings::UEditorPerformanceSettings

Source code excerpt:

	, bMonitorEditorPerformance(false)
	, bEnableScalabilityWarningIndicator(true)
	, bDisplayHighDPIViewports(true)
	, bOverridePIEScreenPercentage(true)
	, RealtimeScreenPercentageMode(EEditorUserScreenPercentageModeOverride::ProjectDefault)
	, MobileScreenPercentageMode(EEditorUserScreenPercentageModeOverride::ProjectDefault)
	, VRScreenPercentageMode(EEditorUserScreenPercentageModeOverride::ProjectDefault)
	, PathTracerScreenPercentageMode(EEditorUserScreenPercentageModeOverride::ProjectDefault)
	, NonRealtimeScreenPercentageMode(EEditorUserScreenPercentageModeOverride::ProjectDefault)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:41

Scope (from outer to inner):

file
function     void UEditorPerformanceSettings::PostInitProperties

Source code excerpt:

	Super::PostInitProperties();

	CVarEditorViewportHighDPI->Set(bDisplayHighDPIViewports != 0, ECVF_SetByProjectSetting);
	CVarEditorViewportOverrideGameScreenPercentage->Set(bOverridePIEScreenPercentage != 0, ECVF_SetByProjectSetting);

	if (FProperty* EnableVSyncProperty = GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, bEnableVSync)))
	{
		ExportValuesToConsoleVariables(EnableVSyncProperty);
	}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorPerformanceSettings.cpp:61

Scope (from outer to inner):

file
function     void UEditorPerformanceSettings::PostEditChangeProperty

Source code excerpt:

	}
		
	if (PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, bDisplayHighDPIViewports) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, RealtimeScreenPercentageMode) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, MobileScreenPercentageMode) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, VRScreenPercentageMode) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, PathTracerScreenPercentageMode) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, NonRealtimeScreenPercentageMode) ||
		PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UEditorPerformanceSettings, bOverrideManualScreenPercentage) ||