r.Ortho.Debug.ForceCameraNearPlane
r.Ortho.Debug.ForceCameraNearPlane
#Overview
name: r.Ortho.Debug.ForceCameraNearPlane
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Debug Force Ortho Near Plane when creating a new camera actor
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Ortho.Debug.ForceCameraNearPlane is to force a specific near plane value for orthographic cameras during debug sessions. This setting is primarily used in the camera system of Unreal Engine 5.
This setting variable is relied upon by the Engine module, specifically within the camera stack system. It’s used in the process of calculating projection matrices for orthographic cameras.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of DEFAULT_ORTHONEARPLANE.
The associated variable CVarDebugForceCameraOrthoNearPlane directly interacts with r.Ortho.Debug.ForceCameraNearPlane. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable is intended for debugging purposes only. It forces a specific near plane value for orthographic cameras, which can be useful for isolating issues related to camera setup but should not be relied upon for normal gameplay or production builds.
Best practices when using this variable include:
- Only use it for debugging purposes.
- Remember to reset it to its default value after debugging.
- Be cautious about using it in multiplayer scenarios, as it might cause visual discrepancies between clients.
Regarding the associated variable CVarDebugForceCameraOrthoNearPlane:
The purpose of CVarDebugForceCameraOrthoNearPlane is to provide a programmatic interface to the r.Ortho.Debug.ForceCameraNearPlane console variable. It allows C++ code to directly access and modify the debug near plane value for orthographic cameras.
This variable is used within the Engine module, specifically in the camera stack system for calculating projection matrices.
The value of CVarDebugForceCameraOrthoNearPlane is set when r.Ortho.Debug.ForceCameraNearPlane is set, as they are directly linked.
It interacts directly with the r.Ortho.Debug.ForceCameraNearPlane console variable, effectively serving as its C++ representation.
Developers should be aware that modifying this variable will affect all orthographic cameras in the scene during debug sessions. It’s important to use it judiciously and remember to reset it when done debugging.
Best practices for using CVarDebugForceCameraOrthoNearPlane include:
- Use GetValueOnAnyThread() to safely access its value from any thread.
- Consider wrapping usage of this variable in preprocessor macros to easily disable it in shipping builds.
- Document any temporary usage of this variable in debug sessions to ensure it’s not accidentally left modified.
#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:82
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDebugForceCameraOrthoNearPlane(
TEXT("r.Ortho.Debug.ForceCameraNearPlane"),
DEFAULT_ORTHONEARPLANE,
TEXT("Debug Force Ortho Near Plane when creating a new camera actor"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarDebugForceCameraOrthoFarPlane(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDebugForceCameraOrthoNearPlane
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:81
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarDebugForceCameraOrthoNearPlane(
TEXT("r.Ortho.Debug.ForceCameraNearPlane"),
DEFAULT_ORTHONEARPLANE,
TEXT("Debug Force Ortho Near Plane when creating a new camera actor"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:225
Scope (from outer to inner):
file
function void FMinimalViewInfo::CalculateProjectionMatrixGivenViewRectangle
Source code excerpt:
ViewInfo.OrthoWidth = CVarDebugForceCameraOrthoWidth.GetValueOnAnyThread();
ViewInfo.bAutoCalculateOrthoPlanes = CVarDebugForceUseOrthoAutoPlanes.GetValueOnAnyThread();
ViewInfo.OrthoNearClipPlane = CVarDebugForceCameraOrthoNearPlane.GetValueOnAnyThread();
ViewInfo.OrthoFarClipPlane = CVarDebugForceCameraOrthoFarPlane.GetValueOnAnyThread();
}
#endif
bool bOrthographic = ViewInfo.ProjectionMode == ECameraProjectionMode::Orthographic;
if(bOrthographic)