Slate.Contrast

Slate.Contrast

#Overview

name: Slate.Contrast

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 Slate.Contrast is to control the amount of contrast applied to the Unreal Engine’s user interface (UI). This setting variable is primarily used in the Slate UI system, which is responsible for rendering the engine’s user interface elements.

Unreal Engine subsystems that rely on this setting variable include:

  1. The SlateCore module, where the variable is defined and initialized.
  2. The SlateRHIRenderer module, which uses the variable for rendering UI elements.

The value of this variable is set through the console variable system. It’s initialized with a default value of 1 in the SlateCore module and can be adjusted at runtime using the console command “Slate.Contrast”.

The associated variable GSlateContrast interacts directly with Slate.Contrast. They share the same value, with GSlateContrast being the actual float variable used in the code, while Slate.Contrast is the console variable name used for external access and modification.

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

  1. Changing the contrast can affect the overall look and feel of the UI.
  2. The default value is 1, which represents normal contrast.
  3. Values higher than 1 will increase contrast, while values lower than 1 will decrease it.
  4. This setting affects all Slate UI elements globally.

Best practices when using this variable include:

  1. Use it sparingly and test thoroughly, as changes can impact UI readability.
  2. Consider accessibility implications when adjusting contrast.
  3. If making changes, document the new value and the reasoning behind it for other team members.
  4. Use the console variable system to experiment with different values during development before settling on a final value.

Regarding the associated variable GSlateContrast: The purpose of GSlateContrast is to store the actual float value of the contrast setting used by the Slate rendering system. It’s the internal representation of the Slate.Contrast console variable.

GSlateContrast is used directly in the SlateRHIRenderer module for applying contrast to UI elements during rendering. It’s defined as an external variable in the SlateCore module, making it accessible across different parts of the engine that deal with UI rendering.

The value of GSlateContrast is set through the console variable system, specifically through the Slate.Contrast command. Any changes to Slate.Contrast will directly affect GSlateContrast.

Developers should be aware that modifying GSlateContrast directly in code is not recommended. Instead, they should use the console variable system to ensure consistency and proper updating of the UI system.

Best practices for GSlateContrast include:

  1. Treat it as a read-only variable in most cases, using the console variable system for modifications.
  2. If reading the value in code, be aware that it can change at runtime.
  3. Consider caching the value if used frequently in performance-critical sections, but ensure to update the cache if the console variable changes.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/SlateCoreClasses.cpp:22

Scope: file

Source code excerpt:


FAutoConsoleVariableRef CVarSlateContrast(
	TEXT("Slate.Contrast"),
	GSlateContrast,
	TEXT("The amount of contrast to apply to the UI (default 1).")
);

// When async lazily loading fonts, when we finish we bump the generation version to
// tell the text layout engine that we need a new pass now that new glyphs will actually

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/SlateCoreClasses.cpp:19

Scope: file

Source code excerpt:



float GSlateContrast = 1;

FAutoConsoleVariableRef CVarSlateContrast(
	TEXT("Slate.Contrast"),
	GSlateContrast,
	TEXT("The amount of contrast to apply to the UI (default 1).")
);

// When async lazily loading fonts, when we finish we bump the generation version to
// tell the text layout engine that we need a new pass now that new glyphs will actually
// be available now to measure and render.

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Public/Types/SlateConstants.h:10

Scope: file

Source code excerpt:


/**  */
extern SLATECORE_API float GSlateContrast;

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

Scope: file

Source code excerpt:

	const float EngineGamma = (!GIsEditor && (BackBuffer.GetRenderTargetTexture()->GetFormat() == PF_FloatRGBA) && (Params.bIsHDR==false)) ? 1.0f : GEngine ? GEngine->GetDisplayGamma() : 2.2f;
	const float DisplayGamma = bGammaCorrect ? EngineGamma : 1.0f;
	const float DisplayContrast = GSlateContrast;

	int32 ScissorClips = 0;
	int32 StencilClips = 0;

	// In order to support MaterialParameterCollections, we need to create multiple FSceneViews for 
	// each possible Scene that we encounter. The following code creates these as separate arrays, where the first