r.Ortho.AutoPlanes.ClampToMaxFPBuffer
r.Ortho.AutoPlanes.ClampToMaxFPBuffer
#Overview
name: r.Ortho.AutoPlanes.ClampToMaxFPBuffer
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When auto evaluating clip planes, determines whether 16bit depth scaling should be used.16bit scaling is advantageous for any depth downscaling that occurs (e.g. HZB downscaling uses 16 bit textures instead of 32).This feature will calculate the maximum depth scale needed based on the Unreal Unit (cm by default) to Pixel ratio.It assumes that we don\'t need 32bit depth range for smaller scenes, because most actors will be within a reasonable visible frustumHowever it does still scale up to a maximum of UE_OLD_WORLD_MAX which is the typical full range of the depth buffer, so larger scenes still work too.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Ortho.AutoPlanes.ClampToMaxFPBuffer is to control the depth buffer precision for orthographic projections in Unreal Engine’s rendering system. It determines whether 16-bit depth scaling should be used when automatically evaluating clip planes for orthographic views.
This setting variable is primarily used by the Engine’s camera and rendering subsystems. It is referenced in the CameraStackTypes.cpp file, which is part of the Engine module.
The value of this variable is set through a console variable (CVarOrthoClampToMaxFPBuffer) with a default value of 1 (enabled). It can be changed at runtime through console commands or project settings.
This variable interacts with other related variables such as CVarOrthoScaleIncrementingUnits and CVarOrthoAutoDepthScale. Together, they control how the depth buffer is scaled and optimized for orthographic projections.
Developers should be aware that enabling this feature (value set to 1) can improve performance for depth buffer downscaling operations, especially for smaller scenes. It assumes that most actors will be within a reasonable visible frustum, allowing for optimized 16-bit depth precision in many cases.
Best practices when using this variable include:
- Consider the scale of your scene when deciding whether to enable or disable this feature.
- Test your project with both settings (0 and 1) to determine which provides the best balance of visual quality and performance for your specific use case.
- Be aware of potential precision issues in very large scenes when this feature is enabled.
Regarding the associated variable CVarOrthoClampToMaxFPBuffer:
This is the actual console variable that controls the r.Ortho.AutoPlanes.ClampToMaxFPBuffer setting. It is defined as a TAutoConsoleVariable
The purpose of CVarOrthoClampToMaxFPBuffer is to provide a runtime-configurable way to enable or disable the 16-bit depth scaling feature for orthographic projections.
This variable is used in the FMinimalViewInfo::AutoCalculateOrthoPlanes function to determine whether to use 16-bit depth scaling and how to calculate the appropriate depth buffer range.
Developers can modify this variable through console commands or project settings to fine-tune the orthographic projection behavior in their games or applications.
When working with CVarOrthoClampToMaxFPBuffer, developers should:
- Understand the implications of enabling or disabling this feature on their specific scenes and rendering requirements.
- Consider performance impacts, especially for projects that heavily rely on orthographic views or have varying scene scales.
- Test thoroughly with different values to ensure optimal visual quality and performance across all supported hardware configurations.
#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:25
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int> CVarOrthoClampToMaxFPBuffer(
TEXT("r.Ortho.AutoPlanes.ClampToMaxFPBuffer"),
1,
TEXT("When auto evaluating clip planes, determines whether 16bit depth scaling should be used.")
TEXT("16bit scaling is advantageous for any depth downscaling that occurs (e.g. HZB downscaling uses 16 bit textures instead of 32).")
TEXT("This feature will calculate the maximum depth scale needed based on the Unreal Unit (cm by default) to Pixel ratio.")
TEXT("It assumes that we don't need 32bit depth range for smaller scenes, because most actors will be within a reasonable visible frustum")
TEXT("However it does still scale up to a maximum of UE_OLD_WORLD_MAX which is the typical full range of the depth buffer, so larger scenes still work too."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarOrthoClampToMaxFPBuffer
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:24
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int> CVarOrthoClampToMaxFPBuffer(
TEXT("r.Ortho.AutoPlanes.ClampToMaxFPBuffer"),
1,
TEXT("When auto evaluating clip planes, determines whether 16bit depth scaling should be used.")
TEXT("16bit scaling is advantageous for any depth downscaling that occurs (e.g. HZB downscaling uses 16 bit textures instead of 32).")
TEXT("This feature will calculate the maximum depth scale needed based on the Unreal Unit (cm by default) to Pixel ratio.")
TEXT("It assumes that we don't need 32bit depth range for smaller scenes, because most actors will be within a reasonable visible frustum")
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:350
Scope (from outer to inner):
file
function bool FMinimalViewInfo::AutoCalculateOrthoPlanes
Source code excerpt:
{
//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;
const float AutoDepthScale = CVarOrthoAutoDepthScale.GetValueOnAnyThread();
if (AutoDepthScale > 0.0f)