r.ShaderPrint.DrawOccludedLines

r.ShaderPrint.DrawOccludedLines

#Overview

name: r.ShaderPrint.DrawOccludedLines

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.ShaderPrint.DrawOccludedLines is to control whether occluded lines are drawn using checkboarding and lower opacity in shader print debugging visualizations.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the ShaderPrint namespace. It is part of the shader debugging and visualization system.

The value of this variable is set through a console variable (CVar) system. It is defined as a TAutoConsoleVariable with an initial value of 1 (enabled by default).

The associated variable CVarDrawOccludedLines directly interacts with r.ShaderPrint.DrawOccludedLines. They share the same value and purpose.

Developers should be aware that:

  1. This variable affects the visibility of debug lines that would otherwise be occluded in the scene.
  2. It is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags, indicating it’s intended for debugging/development use and can be safely modified on the render thread.

Best practices when using this variable include:

  1. Use it primarily during development and debugging phases.
  2. Be aware that enabling this feature may have a performance impact, especially in complex scenes.
  3. Consider disabling it in shipping builds to avoid any potential performance overhead.

Regarding the associated variable CVarDrawOccludedLines:

The purpose of CVarDrawOccludedLines is identical to r.ShaderPrint.DrawOccludedLines. It’s an internal representation of the console variable within the engine’s code.

This variable is used directly in the rendering code to determine whether to draw occluded lines. For example, in the InternalDrawView_Primitives function, its value is queried and passed to the shader parameters.

The value of CVarDrawOccludedLines is set when the console variable r.ShaderPrint.DrawOccludedLines is modified.

Developers should be aware that changes to r.ShaderPrint.DrawOccludedLines will directly affect the behavior controlled by CVarDrawOccludedLines.

Best practices for CVarDrawOccludedLines are the same as for r.ShaderPrint.DrawOccludedLines, as they are essentially two sides of the same coin - one being the console-accessible variable, and the other being its internal representation in the engine code.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarDrawOccludedLines(
		TEXT("r.ShaderPrint.DrawOccludedLines"),
		1,
		TEXT("Whether to draw occluded lines using checkboarding and lower opacity.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarDrawZoomEnable(
		TEXT("r.ShaderPrint.Zoom"),

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarDrawOccludedLines(
		TEXT("r.ShaderPrint.DrawOccludedLines"),
		1,
		TEXT("Whether to draw occluded lines using checkboarding and lower opacity.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarDrawZoomEnable(

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

Scope (from outer to inner):

file
namespace    ShaderPrint
function     static void InternalDrawView_Primitives

Source code excerpt:

		PassParameters->PS.DepthSampler = TStaticSamplerState<SF_Point, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();
		PassParameters->PS.bCheckerboardEnabled = bLines ? 1u : 0u;
		PassParameters->PS.bDrawOccludedLines = CVarDrawOccludedLines.GetValueOnRenderThread() != 0 ? 1 : 0;
		PassParameters->VS.ShaderDrawDebugPrimitive = ShaderPrintPrimitiveBufferSRV;
		PassParameters->VS.IndirectBuffer = IndirectBuffer;
		PassParameters->VS.Common = ShaderPrintData.UniformBuffer;

		ValidateShaderParameters(PixelShader, PassParameters->PS);
		ClearUnusedGraphResources(PixelShader, &PassParameters->PS, { IndirectBuffer });