r.Ortho.Debug.ForceUseAutoPlanes

r.Ortho.Debug.ForceUseAutoPlanes

#Overview

name: r.Ortho.Debug.ForceUseAutoPlanes

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.Ortho.Debug.ForceUseAutoPlanes is to debug and force the use of automatic near and far plane evaluation for orthographic camera projections in Unreal Engine 5.

This setting variable is primarily used by the camera system within the Engine module. It’s specifically utilized in the process of calculating projection matrices for orthographic views.

The value of this variable is set through a console variable (CVarDebugForceUseOrthoAutoPlanes) in the Engine’s camera stack types implementation. It’s initialized with a default value of true.

This variable interacts with several other debug-related variables for orthographic camera settings, such as CVarDebugForceCameraOrthoNearPlane and CVarDebugForceCameraOrthoFarPlane. Together, these variables allow developers to override and debug various aspects of orthographic camera projections.

Developers must be aware that this is a debug-only variable, intended for testing and troubleshooting purposes. It should not be relied upon for production gameplay or rendering logic.

Best practices when using this variable include:

  1. Use it only for debugging purposes, not in production code.
  2. Be aware that it may affect the rendering performance and visual output when enabled.
  3. Use it in conjunction with other orthographic camera debug variables for comprehensive testing.

Regarding the associated variable CVarDebugForceUseOrthoAutoPlanes:

This is the actual console variable that controls the r.Ortho.Debug.ForceUseAutoPlanes setting. It’s defined as a boolean TAutoConsoleVariable, which means it can be changed at runtime through the console.

The purpose of CVarDebugForceUseOrthoAutoPlanes is to provide a runtime-configurable way to enable or disable the automatic near and far plane evaluation for orthographic cameras.

This variable is used within the Engine module, specifically in the camera stack implementation. It’s accessed in the FMinimalViewInfo::CalculateProjectionMatrixGivenViewRectangle function to determine whether automatic orthographic planes should be used.

The value of this variable can be set through the Unreal Engine console or through code using the console variable system.

Developers should be aware that changes to this variable will immediately affect the behavior of orthographic cameras in the scene. It’s important to reset it to its default state after debugging to ensure consistent behavior.

Best practices for using CVarDebugForceUseOrthoAutoPlanes include:

  1. Use it in conjunction with other orthographic camera debug variables for comprehensive testing.
  2. Remember to reset it to its default value after debugging sessions.
  3. Consider creating a debugging tool or menu in your game to easily toggle this and related debug variables during development.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:75

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarDebugForceUseOrthoAutoPlanes(
	TEXT("r.Ortho.Debug.ForceUseAutoPlanes"),
	true,
	TEXT("Debug Force boolean for whether to use the automatic near and far plane evaluation"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<float> CVarDebugForceCameraOrthoNearPlane(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:74

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarDebugForceUseOrthoAutoPlanes(
	TEXT("r.Ortho.Debug.ForceUseAutoPlanes"),
	true,
	TEXT("Debug Force boolean for whether to use the automatic near and far plane evaluation"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:224

Scope (from outer to inner):

file
function     void FMinimalViewInfo::CalculateProjectionMatrixGivenViewRectangle

Source code excerpt:

		ViewInfo.ProjectionMode = ECameraProjectionMode::Orthographic;
		ViewInfo.OrthoWidth = CVarDebugForceCameraOrthoWidth.GetValueOnAnyThread();
		ViewInfo.bAutoCalculateOrthoPlanes = CVarDebugForceUseOrthoAutoPlanes.GetValueOnAnyThread();
		ViewInfo.OrthoNearClipPlane = CVarDebugForceCameraOrthoNearPlane.GetValueOnAnyThread();
		ViewInfo.OrthoFarClipPlane = CVarDebugForceCameraOrthoFarPlane.GetValueOnAnyThread();
	}
#endif

	bool bOrthographic = ViewInfo.ProjectionMode == ECameraProjectionMode::Orthographic;