r.HDR.Display.MidLuminance

r.HDR.Display.MidLuminance

#Overview

name: r.HDR.Display.MidLuminance

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.HDR.Display.MidLuminance is to configure the display output nit level for 18% gray in HDR rendering. This setting is crucial for the High Dynamic Range (HDR) rendering system in Unreal Engine 5.

This setting variable is primarily used by the rendering subsystem of Unreal Engine. Specifically, it’s utilized in the HDR configuration and tone mapping processes.

The value of this variable is set in the RenderCore.cpp file, with a default value of 15.0f. It can be modified at runtime through the console variable system.

The r.HDR.Display.MidLuminance variable interacts with several other HDR-related variables, including:

Developers must be aware that this variable directly affects the HDR rendering pipeline. Changing its value will impact the overall brightness and contrast of the HDR output. It’s particularly important for achieving accurate color grading and maintaining visual consistency across different HDR displays.

Best practices when using this variable include:

  1. Calibrating it based on the target display device’s capabilities.
  2. Coordinating its value with other HDR settings for a balanced output.
  3. Testing the visual results across various HDR-capable displays to ensure consistency.

Regarding the associated variable CVarHDRDisplayMidLuminance:

This is the internal representation of the r.HDR.Display.MidLuminance console variable. It’s used within the engine’s C++ code to access and modify the HDR mid luminance value.

The purpose of CVarHDRDisplayMidLuminance is to provide a programmatic interface to the r.HDR.Display.MidLuminance setting. It’s used in the HDR configuration process, specifically in the ConfigureACESTonemapParams function, which sets up the ACES (Academy Color Encoding System) tonemapping parameters.

This variable is primarily used in the RenderCore module of Unreal Engine. It’s accessed in the HDRConfigureCVars function, which is likely called when HDR settings need to be updated or reconfigured.

The value of CVarHDRDisplayMidLuminance is set and modified through the console variable system, mirroring the r.HDR.Display.MidLuminance setting.

Developers should be aware that changes to CVarHDRDisplayMidLuminance will immediately affect the HDR rendering pipeline. It’s typically not manipulated directly in code but rather through the console variable system.

Best practices for using CVarHDRDisplayMidLuminance include:

  1. Accessing its value using the GetValueOnAnyThread() method when needed in rendering code.
  2. Avoiding direct manipulation of this variable; instead, modify the r.HDR.Display.MidLuminance console variable.
  3. Consider the impact on the entire HDR pipeline when changing this value, as it affects the ACES tonemapping configuration.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:386

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarHDRDisplayMidLuminance(
	TEXT("r.HDR.Display.MidLuminance"),
	15.0f,
	TEXT("The configured display output nit level for 18% gray"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarHDRDisplayMaxLuminance(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:948

Scope (from outer to inner):

file
function     void HDRSettingChangedSinkCallback

Source code excerpt:

	check(CVarHDROutputEnabled);
	static const auto CVarHDRMinLuminanceLog10 = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.HDR.Display.MinLuminanceLog10"));
	static const auto CVarHDRMidLuminance = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.HDR.Display.MidLuminance"));
	static const auto CVarHDRMaxLuminance = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.MaxLuminance"));
	static const auto CVarHDRSceneColorMultiplier = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.HDR.Aces.SceneColorMultiplier"));
	static const auto CVarHDRGamutCompression = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.HDR.Aces.GamutCompression"));

	if (GRHIVendorId == 0)
	{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:385

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarHDRDisplayMidLuminance(
	TEXT("r.HDR.Display.MidLuminance"),
	15.0f,
	TEXT("The configured display output nit level for 18% gray"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:641

Scope (from outer to inner):

file
function     void HDRConfigureCVars

Source code excerpt:


	float HDRDisplayMinLuminance = FMath::Pow(10, CVarHDRDisplayMinLuminanceLog10.GetValueOnAnyThread());
	ConfigureACESTonemapParams(GACESTonemapParams, HDRDisplayMinLuminance, CVarHDRDisplayMidLuminance.GetValueOnAnyThread(), CVarHDRDisplayMaxLuminance.GetValueOnAnyThread());
}

RENDERCORE_API FMatrix44f GamutToXYZMatrix(EDisplayColorGamut ColorGamut)
{
	static const FMatrix44f sRGB_2_XYZ_MAT(
		FVector3f(0.4124564, 0.3575761, 0.1804375),