r.HDR.UI.Level

r.HDR.UI.Level

#Overview

name: r.HDR.UI.Level

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.UI.Level is to control the luminance level for UI elements when compositing them into an HDR framebuffer in Unreal Engine 5.

This setting variable is primarily used in the SlateRHIRenderer module, which is responsible for rendering Slate UI elements in Unreal Engine. Specifically, it’s used in the HDR compositing process for UI elements.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0f and can be changed at runtime through console commands or programmatically.

The r.HDR.UI.Level variable interacts closely with another variable called r.HDR.UI.Luminance. While r.HDR.UI.Level controls the overall luminance level, r.HDR.UI.Luminance seems to be used for more specific luminance calculations.

Developers should be aware that this variable directly affects the appearance of UI elements in HDR rendering. Adjusting this value will change how bright or dim UI elements appear relative to the HDR content.

Best practices when using this variable include:

  1. Testing UI visibility across different HDR displays and content to ensure readability.
  2. Considering the interplay between this variable and r.HDR.UI.Luminance for fine-tuning UI appearance.
  3. Being cautious when modifying this value, as it can significantly impact the user experience.

Regarding the associated variable CVarUILevel:

The purpose of CVarUILevel is to serve as the actual console variable that stores and provides access to the r.HDR.UI.Level value within the engine’s code.

It’s used in the same SlateRHIRenderer module, specifically in shader parameter setting for UI compositing.

The value of CVarUILevel is set when the r.HDR.UI.Level console command is used or when the value is changed programmatically.

CVarUILevel interacts directly with shader parameters, passing its value to the GPU for use in rendering calculations.

Developers should be aware that CVarUILevel is the programmatic interface for accessing and modifying the r.HDR.UI.Level value. Any runtime changes to this value should be made through CVarUILevel.

Best practices for CVarUILevel include:

  1. Using GetValueOnRenderThread() when accessing the value in render thread code to ensure thread safety.
  2. Considering caching the console variable pointer for frequent access rather than looking it up each time.
  3. Being aware of the performance implications of frequently changing this value, as it may trigger shader recompilations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:72

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarUILevel(
	TEXT("r.HDR.UI.Level"),
	1.0f,
	TEXT("Luminance level for UI elements when compositing into HDR framebuffer (default: 1.0)."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarHDRUILuminance(
	TEXT("r.HDR.UI.Luminance"),

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlatePostProcessor.cpp:90

Scope (from outer to inner):

file
class        class FBlitUIToHDRPSBase : public FGlobalShader
function     void SetParameters

Source code excerpt:

		SetTextureParameter(BatchedParameters, HDRTexture, UISampler, TStaticSamplerState<SF_Bilinear>::GetRHI(), HDRTextureRHI);
		SetTextureParameter(BatchedParameters, UITexture, UISampler, TStaticSamplerState<SF_Bilinear>::GetRHI(), UITextureRHI);
		static auto CVarHDRUILevel = IConsoleManager::Get().FindConsoleVariable(TEXT("r.HDR.UI.Level"));
		static auto CVarHDRUILuminance = IConsoleManager::Get().FindConsoleVariable(TEXT("r.HDR.UI.Luminance"));
		SetShaderValue(BatchedParameters, UILevel, CVarHDRUILevel ? CVarHDRUILevel->GetFloat() : 1.0f);
		SetShaderValue(BatchedParameters, UILuminance, CVarHDRUILuminance ? CVarHDRUILuminance->GetFloat() : 300.0f);
		SetShaderValue(BatchedParameters, UITextureSize, InUITextureSize);
		if (UITextureWriteMaskRHI != nullptr)
		{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:71

Scope: file

Source code excerpt:

#define MAX_VIEWPORT_SIZE 16384

static TAutoConsoleVariable<float> CVarUILevel(
	TEXT("r.HDR.UI.Level"),
	1.0f,
	TEXT("Luminance level for UI elements when compositing into HDR framebuffer (default: 1.0)."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarHDRUILuminance(

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:773

Scope (from outer to inner):

file
class        class FCompositeShaderBase : public FGlobalShader
function     void SetParametersBase

Source code excerpt:

		SetTextureParameter(BatchedParameters, UITexture, UISampler, TStaticSamplerState<SF_Point>::GetRHI(), UITextureRHI);
		SetTextureParameter(BatchedParameters, ColorSpaceLUT, ColorSpaceLUTSampler, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI(), ColorSpaceLUTRHI);
		SetShaderValue(BatchedParameters, UILevel, CVarUILevel.GetValueOnRenderThread());
		SetShaderValue(BatchedParameters, OutputDevice, CVarOutputDevice->GetValueOnRenderThread());
		SetShaderValue(BatchedParameters, UILuminance, CVarHDRUILuminance.GetValueOnRenderThread());

		if (UITextureWriteMaskRHI != nullptr)
		{
			SetTextureParameter(BatchedParameters, UIWriteMaskTexture, UITextureWriteMaskRHI);