r.DebugSafeZone.OverlayAlpha

r.DebugSafeZone.OverlayAlpha

#Overview

name: r.DebugSafeZone.OverlayAlpha

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.DebugSafeZone.OverlayAlpha is to control the opacity of the safe zone visualization overlay in Unreal Engine 5. This setting is specifically used for debugging and visualizing the safe zone areas on the screen.

This setting variable is primarily used by the rendering system, specifically for HUD and viewport rendering. It is utilized in the Engine module, particularly in the HUD and GameViewportClient classes.

The value of this variable is set through the console variable system. It is initialized with a default value of 0.2f, but can be changed at runtime through console commands or programmatically.

The associated variable GSafeZoneVisualizationAlphaCVar interacts directly with r.DebugSafeZone.OverlayAlpha. They share the same value and purpose, with GSafeZoneVisualizationAlphaCVar being the actual TAutoConsoleVariable instance that holds the value.

Developers should be aware that this variable affects the visibility of the safe zone overlay. A higher value will make the overlay more opaque, while a lower value will make it more transparent. The value range is from 0 to 1, where 0 is fully transparent and 1 is fully opaque.

Best practices when using this variable include:

  1. Use it only for debugging purposes, not in production builds.
  2. Adjust the value to find a balance between visibility and non-intrusiveness.
  3. Remember to disable or set to 0 when not actively debugging safe zones.

Regarding the associated variable GSafeZoneVisualizationAlphaCVar:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:46

Scope: file

Source code excerpt:

// How opaque should the safe zone visualization be?
TAutoConsoleVariable<float> GSafeZoneVisualizationAlphaCVar(
	TEXT("r.DebugSafeZone.OverlayAlpha"),
	0.2f,
	TEXT("The alpha value of the safe zone overlay (0..1)\n")
	TEXT(" default: 0.2"));

TAutoConsoleVariable<int32> GMaxDebugTextStringsPerActorCVar(
	TEXT("r.DebugSafeZone.MaxDebugTextStringsPerActor"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:2851

Scope (from outer to inner):

file
function     void UGameViewportClient::DrawTitleSafeArea

Source code excerpt:


	FLinearColor UnsafeZoneColor(1.0f, 0.0f, 0.0f, 0.25f);
	static IConsoleVariable* AlphaCvar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DebugSafeZone.OverlayAlpha"));
	if (AlphaCvar)
	{
		UnsafeZoneColor.A = AlphaCvar->GetFloat();
	}

	FCanvasTileItem TileItem(FVector2D::ZeroVector, GWhiteTexture, UnsafeZoneColor);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:45

Scope: file

Source code excerpt:


// How opaque should the safe zone visualization be?
TAutoConsoleVariable<float> GSafeZoneVisualizationAlphaCVar(
	TEXT("r.DebugSafeZone.OverlayAlpha"),
	0.2f,
	TEXT("The alpha value of the safe zone overlay (0..1)\n")
	TEXT(" default: 0.2"));

TAutoConsoleVariable<int32> GMaxDebugTextStringsPerActorCVar(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HUD.cpp:271

Scope (from outer to inner):

file
function     void AHUD::DrawSafeZoneOverlay

Source code excerpt:

		FMargin SafeMargin;
		FSlateApplication::Get().GetSafeZoneSize(SafeMargin, FVector2D(Width, Height));
		const float UnsafeZoneAlpha = GSafeZoneVisualizationAlphaCVar.GetValueOnGameThread();
		const FLinearColor UnsafeZoneColor(1.0f, 0.5f, 0.5f, UnsafeZoneAlpha);

		const float HeightOfSides = Height - SafeMargin.GetTotalSpaceAlong<Orient_Vertical>();

		FCanvasTileItem TileItem(FVector2D::ZeroVector, GWhiteTexture, UnsafeZoneColor);
		TileItem.BlendMode = SE_BLEND_Translucent;