r.Ortho.AutoPlanes.DepthScale

r.Ortho.AutoPlanes.DepthScale

#Overview

name: r.Ortho.AutoPlanes.DepthScale

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.DepthScale is to adjust the depth scaling for orthographic projections in the rendering system. It allows fine-tuning of the 16-bit depth buffer utilization, particularly for orthographic cameras.

This setting variable is primarily used in the Unreal Engine’s rendering and camera subsystems, specifically in the Engine module. It’s referenced in the CameraStackTypes.cpp file, which handles camera-related functionality.

The value of this variable is set through a console variable (CVarOrthoAutoDepthScale) with a default value of -1.0f. It can be adjusted at runtime through console commands or programmatically.

The associated variable CVarOrthoAutoDepthScale directly interacts with r.Ortho.AutoPlanes.DepthScale. They share the same value and purpose.

Developers must be aware that:

  1. This variable affects the far plane distance and depth precision in orthographic projections.
  2. It’s only effective when set to a value greater than 0.0f.
  3. The valid range is between 1.0f and the maximum value of a 16-bit float (66504.0f for FP16).

Best practices when using this variable include:

  1. Only adjust it when you need to optimize depth precision for specific orthographic view scenarios.
  2. Consider the trade-off between far plane distance and depth precision when adjusting this value.
  3. Test thoroughly after modifying this value to ensure it doesn’t negatively impact your scene’s rendering.

Regarding the associated variable CVarOrthoAutoDepthScale:

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float>  CVarOrthoAutoDepthScale(
	TEXT("r.Ortho.AutoPlanes.DepthScale"),
	-1.0f,
	TEXT("Allows the 16 bit depth scaling to be adjusted from the  default +FP16 Max (66504.0f)")
	TEXT("This is useful if the far plane doesn't need to be as far away, so it will improve depth deltas"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float>  CVarOrthoAutoDepthScale(
	TEXT("r.Ortho.AutoPlanes.DepthScale"),
	-1.0f,
	TEXT("Allows the 16 bit depth scaling to be adjusted from the  default +FP16 Max (66504.0f)")
	TEXT("This is useful if the far plane doesn't need to be as far away, so it will improve depth deltas"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     bool FMinimalViewInfo::AutoCalculateOrthoPlanes

Source code excerpt:

		float FPScale = bUse16bitDepth ? 66504.0f : UE_OLD_WORLD_MAX;

		const float AutoDepthScale = CVarOrthoAutoDepthScale.GetValueOnAnyThread();
		if (AutoDepthScale > 0.0f)
		{
			//This allows the user to override the FP scaling value, where the default is 16bit.
			FPScale = FMath::Clamp(AutoDepthScale, 1.0f, FPScale);
		}