r.Ortho.AutoPlanes

r.Ortho.AutoPlanes

#Overview

name: r.Ortho.AutoPlanes

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.AutoPlanes is to control whether orthographic cameras in Unreal Engine 5 are allowed to utilize automatic Near/Far plane evaluations. This setting is primarily related to the camera and rendering systems within the engine.

The Unreal Engine subsystem that relies on this setting variable is the camera system, specifically for orthographic camera projections. It’s used in the Engine module, as evidenced by its location in the Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp file.

The value of this variable is set using a TAutoConsoleVariable, which means it can be changed at runtime through console commands. By default, it is set to true, allowing automatic plane evaluations for orthographic cameras.

This variable interacts with another variable named CVarOrthoAllowAutoPlanes, which is the actual C++ variable that stores and provides access to the r.Ortho.AutoPlanes setting. They share the same value and purpose.

Developers must be aware that this setting affects all orthographic cameras in the scene. When enabled, it allows the engine to automatically calculate the near and far planes for orthographic projections, which can be beneficial for performance and rendering accuracy.

Best practices when using this variable include:

  1. Leave it enabled (default) unless there’s a specific need to manually control the near and far planes for orthographic cameras.
  2. If disabled, ensure that manual near and far plane settings are appropriate for the scene to avoid rendering artifacts.
  3. Be aware that changing this setting at runtime may affect all orthographic cameras in the scene.

Regarding the associated variable CVarOrthoAllowAutoPlanes:

The purpose of CVarOrthoAllowAutoPlanes is to provide C++ code access to the r.Ortho.AutoPlanes setting. It’s used internally by the engine to check whether automatic plane calculations should be performed for orthographic cameras.

This variable is part of the camera system in the Engine module. It’s primarily used in the FMinimalViewInfo::AutoCalculateOrthoPlanes function, which is responsible for calculating orthographic projection planes.

The value of CVarOrthoAllowAutoPlanes is set and controlled by the r.Ortho.AutoPlanes console variable. It can be accessed in C++ code using the GetValueOnAnyThread() method.

CVarOrthoAllowAutoPlanes interacts with other variables in the AutoCalculateOrthoPlanes function, such as CVarOrthoClampToMaxFPBuffer and CVarOrthoScaleIncrementingUnits, to determine how to calculate the orthographic projection planes.

Developers should be aware that this variable is used in performance-critical code and should be accessed carefully to avoid unnecessary performance overhead.

Best practices for using CVarOrthoAllowAutoPlanes include:

  1. Use GetValueOnAnyThread() when accessing the value, as it’s thread-safe.
  2. Consider caching the value if it’s accessed frequently in performance-critical code.
  3. Be aware of its impact on orthographic camera behavior when modifying related camera code.

#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:18

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarOrthoAllowAutoPlanes(
	TEXT("r.Ortho.AutoPlanes"),
	true,
	TEXT("Globally allow Ortho cameras to utilise the automatic Near/Far plane evaluations."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int> CVarOrthoClampToMaxFPBuffer(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarOrthoAllowAutoPlanes(
	TEXT("r.Ortho.AutoPlanes"),
	true,
	TEXT("Globally allow Ortho cameras to utilise the automatic Near/Far plane evaluations."),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     bool FMinimalViewInfo::AutoCalculateOrthoPlanes

Source code excerpt:

bool FMinimalViewInfo::AutoCalculateOrthoPlanes(FSceneViewProjectionData& InOutProjectionData)
{	
	if (ProjectionMode == ECameraProjectionMode::Orthographic && CVarOrthoAllowAutoPlanes.GetValueOnAnyThread() && bAutoCalculateOrthoPlanes)
	{
		//First check if we are using 16bit buffer and unit scaling, then set the min/max values accordingly
		const bool bUse16bitDepth = CVarOrthoClampToMaxFPBuffer.GetValueOnAnyThread() == 1;
		const bool bScaleIncrementingUnits = CVarOrthoScaleIncrementingUnits.GetValueOnAnyThread() && bUse16bitDepth;
		const float MaxFPValue = bScaleIncrementingUnits ? UE_LARGE_WORLD_MAX : UE_OLD_WORLD_MAX;
		float FPScale = bUse16bitDepth ? 66504.0f : UE_OLD_WORLD_MAX;