r.HDR.UI.CompositeMode

r.HDR.UI.CompositeMode

#Overview

name: r.HDR.UI.CompositeMode

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.HDR.UI.CompositeMode is to control the mode used when compositing the UI layer in HDR rendering scenarios. This setting variable is specifically for the rendering system, focusing on how the user interface is blended with the main scene in High Dynamic Range (HDR) environments.

This setting variable is primarily used in the SlateRHIRenderer and Engine modules of Unreal Engine 5. It’s referenced in the SlateRHIRenderer for UI composition and in the Engine module for batch element rendering.

The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s defined with a default value of 1, meaning the shader pass to improve HDR blending is enabled by default.

This variable interacts with other HDR-related settings and hardware capabilities. It’s used in conjunction with checks for HDR output support (GRHISupportsHDROutput) and whether HDR is enabled in the current view.

Developers must be aware that this variable only takes effect when HDR rendering is supported and enabled. It’s also important to note that it affects performance, as using the shader pass (mode 1) may have a higher performance cost than standard compositing (mode 0).

Best practices when using this variable include:

  1. Only enable it (set to 1) when HDR rendering is active and UI composition quality is a priority.
  2. Consider performance implications, especially on lower-end hardware.
  3. Test both modes (0 and 1) to determine the best visual quality for your specific UI design.
  4. Be aware that changing this setting might require adjustments to UI element colors or opacity to achieve the desired look in HDR.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarUICompositeMode(
	TEXT("r.HDR.UI.CompositeMode"),
	1,
	TEXT("Mode used when compositing the UI layer:\n")
	TEXT("0: Standard compositing\n")
	TEXT("1: Shader pass to improve HDR blending\n"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/BatchedElements.cpp:443

Scope (from outer to inner):

file
function     static void SetBlendState

Source code excerpt:

{
	// Override blending operations to accumulate alpha
	static const auto CVarCompositeMode = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.UI.CompositeMode"));

	const bool bCompositeUI = GRHISupportsHDROutput
		&& CVarCompositeMode && CVarCompositeMode->GetValueOnRenderThread() != 0 
		&& IsHDREnabled();

	if (bCompositeUI)

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

Scope (from outer to inner):

file
function     inline bool CompositeUIWithHdrRenderTarget

Source code excerpt:

{
	// Optional off-screen UI composition during HDR rendering
	static const auto CVarCompositeMode = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.UI.CompositeMode"));

	const bool bSupportsUIComposition = GRHISupportsHDROutput && GSupportsVolumeTextureRendering && SupportsUICompositionRendering(GetFeatureLevelShaderPlatform(GMaxRHIFeatureLevel));
	const bool bCompositeUI = bSupportsUIComposition
		&& CVarCompositeMode && CVarCompositeMode->GetValueOnAnyThread() != 0
		&& ViewInfo->bSceneHDREnabled;