r.ShaderPrint.FontSpacingX
r.ShaderPrint.FontSpacingX
#Overview
name: r.ShaderPrint.FontSpacingX
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
ShaderPrint horizontal spacing between symbols.\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPrint.FontSpacingX is to control the horizontal spacing between symbols in the ShaderPrint system, which is part of Unreal Engine’s rendering subsystem. This variable allows developers to adjust the layout of debug information rendered directly in shaders.
The ShaderPrint system, which is part of the Renderer module, relies on this setting variable. It’s used specifically in the ShaderPrint namespace within the Renderer’s implementation.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, which means there’s no additional spacing by default between symbols horizontally.
This variable interacts closely with r.ShaderPrint.FontSpacingY, which controls the vertical spacing. Together, they determine the overall layout of the ShaderPrint output.
Developers must be aware that this variable affects the readability and layout of debug information rendered in shaders. Changing this value can impact how densely packed or spread out the text appears horizontally.
Best practices when using this variable include:
- Adjusting it in conjunction with r.ShaderPrint.FontSpacingY for optimal readability.
- Using non-zero values when debug text appears too cramped horizontally.
- Being mindful that very large values might cause text to extend beyond the intended display area.
Regarding the associated variable CVarFontSpacingX:
CVarFontSpacingX is the actual console variable object that controls the r.ShaderPrint.FontSpacingX setting. It’s an instance of TAutoConsoleVariable
The CVarFontSpacingX variable is used in the FShaderPrintSetup constructor to initialize the FontSpacing member. It’s retrieved using the GetValueOnAnyThread() method, which suggests that this value can be safely accessed from any thread.
When using CVarFontSpacingX, developers should note:
- It’s defined with ECVF_Cheat | ECVF_RenderThreadSafe flags, indicating it’s intended for debugging and can be safely changed at runtime.
- The value is clamped to a minimum of 1 when used, ensuring there’s always at least one pixel of spacing.
- Changes to this variable will take effect the next time FShaderPrintSetup is constructed, which typically happens each frame when ShaderPrint is active.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:36
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
static TAutoConsoleVariable<int32> CVarFontSpacingX(
TEXT("r.ShaderPrint.FontSpacingX"),
0,
TEXT("ShaderPrint horizontal spacing between symbols.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarFontSpacingY(
TEXT("r.ShaderPrint.FontSpacingY"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarFontSpacingX
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:35
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarFontSpacingX(
TEXT("r.ShaderPrint.FontSpacingX"),
0,
TEXT("ShaderPrint horizontal spacing between symbols.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarFontSpacingY(
#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;
}