r.ShaderPrint.FontSpacingY

r.ShaderPrint.FontSpacingY

#Overview

name: r.ShaderPrint.FontSpacingY

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.ShaderPrint.FontSpacingY is to control the vertical spacing between symbols in the ShaderPrint system, which is part of Unreal Engine’s rendering subsystem.

This setting variable is primarily used within the Renderer module of Unreal Engine 5. Specifically, it’s utilized in the ShaderPrint namespace, which suggests it’s part of a system for printing or displaying debug information directly in shaders.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 8, but can be changed at runtime using console commands or through code.

The r.ShaderPrint.FontSpacingY variable interacts closely with another variable named CVarFontSpacingY. They share the same value, as CVarFontSpacingY is the actual TAutoConsoleVariable object that represents r.ShaderPrint.FontSpacingY in the code.

Developers should be aware that this variable affects the visual layout of shader-printed text. Changing it will alter the vertical spacing between lines of debug text rendered in the shader.

Best practices when using this variable include:

  1. Only modify it when necessary for readability of shader-printed debug information.
  2. Consider the relationship with r.ShaderPrint.FontSpacingX for consistent text layout.
  3. Be mindful that very small values might cause text overlap, while very large values could spread text too far apart.

Regarding the associated variable CVarFontSpacingY:

The purpose of CVarFontSpacingY is to provide programmatic access to the r.ShaderPrint.FontSpacingY setting within the C++ code.

It’s used in the Renderer module, specifically within the ShaderPrint namespace. This variable is crucial for the internal workings of the ShaderPrint system.

The value of CVarFontSpacingY is set when r.ShaderPrint.FontSpacingY is modified, as they represent the same setting.

CVarFontSpacingY interacts with other variables in the FShaderPrintSetup struct, particularly FontSpacing, which uses its value to determine the vertical component of font spacing.

Developers should be aware that CVarFontSpacingY is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags, indicating it’s intended for debugging and is safe to modify from the render thread.

Best practices for using CVarFontSpacingY include:

  1. Access its value using GetValueOnAnyThread() when needed in rendering code.
  2. Ensure any modifications are thread-safe, as it’s accessed in rendering contexts.
  3. Use it in conjunction with CVarFontSpacingX for consistent text layout in shader prints.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:42

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarFontSpacingY(
		TEXT("r.ShaderPrint.FontSpacingY"),
		8,
		TEXT("ShaderPrint vertical spacing between symbols.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxCharacterCount(
		TEXT("r.ShaderPrint.MaxCharacters"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:41

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarFontSpacingY(
		TEXT("r.ShaderPrint.FontSpacingY"),
		8,
		TEXT("ShaderPrint vertical spacing between symbols.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxCharacterCount(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:729

Scope (from outer to inner):

file
namespace    ShaderPrint
function     FShaderPrintSetup::FShaderPrintSetup

Source code excerpt:


		FontSize = FIntPoint(FMath::Max(CVarFontSize.GetValueOnAnyThread(), 1), FMath::Max(CVarFontSize.GetValueOnAnyThread(), 1));
		FontSpacing = FIntPoint(FMath::Max(CVarFontSpacingX.GetValueOnAnyThread(), 1), FMath::Max(CVarFontSpacingY.GetValueOnAnyThread(), 1));
		MaxCharacterCount = bEnabled ? GetMaxCharacterCount() : 0;
		MaxStateCount = bEnabled ? GetMaxWidgetCount() : 0;
		MaxLineCount = bEnabled ? GetMaxLineCount() : 0;
		MaxTriangleCount = bEnabled ? GetMaxTriangleCount(): 0;
		bIsDrawLocked = false;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:747

Scope (from outer to inner):

file
namespace    ShaderPrint
function     FShaderPrintSetup::FShaderPrintSetup

Source code excerpt:


		FontSize = FIntPoint(FMath::Max(CVarFontSize.GetValueOnAnyThread(), 1), FMath::Max(CVarFontSize.GetValueOnAnyThread(), 1));
		FontSpacing = FIntPoint(FMath::Max(CVarFontSpacingX.GetValueOnAnyThread(), 1), FMath::Max(CVarFontSpacingY.GetValueOnAnyThread(), 1));
		MaxCharacterCount = bEnabled ? GetMaxCharacterCount() : 0;
		MaxStateCount = bEnabled ? GetMaxWidgetCount() : 0;
		MaxLineCount = bEnabled ? GetMaxLineCount() : 0;
		MaxTriangleCount = bEnabled ? GetMaxTriangleCount() : 0;
		bIsDrawLocked = View.State ? ((const FSceneViewState*)View.State)->ShaderPrintStateData.bIsLocked : false;
	}