r.UseLegacyMaintainYFOVViewMatrix
r.UseLegacyMaintainYFOVViewMatrix
#Overview
name: r.UseLegacyMaintainYFOVViewMatrix
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use the old way to compute perspective view matrices when the aspect ratio constraint is vertical
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.UseLegacyMaintainYFOVViewMatrix is to control the method used for computing perspective view matrices when the aspect ratio constraint is vertical. This setting is related to the camera and rendering systems in Unreal Engine 5.
This setting variable is primarily used in the Engine module, specifically in the camera stack types implementation. It affects how the engine calculates projection matrices for the camera view.
The value of this variable is set through a console variable (CVar) system. It is defined as a static TAutoConsoleVariable with a default value of false. This means that by default, the engine uses the new method for computing perspective view matrices.
The associated variable CVarUseLegacyMaintainYFOV directly interacts with r.UseLegacyMaintainYFOVViewMatrix. They share the same value and purpose.
Developers must be aware that changing this variable will affect how the engine computes perspective view matrices, which can impact the rendering output, especially in scenarios where the aspect ratio constraint is vertical. This could potentially affect the appearance of the game view and how objects are displayed on screen.
Best practices when using this variable include:
- Only modify this setting if you encounter specific issues with camera perspective in vertically constrained aspect ratios.
- Test thoroughly after changing this setting, as it can affect the entire rendering pipeline.
- Document any changes to this setting in your project, as it may impact how other developers work with camera and rendering systems.
Regarding the associated variable CVarUseLegacyMaintainYFOV:
The purpose of CVarUseLegacyMaintainYFOV is identical to r.UseLegacyMaintainYFOVViewMatrix. It’s used internally in the engine code to access the value of the console variable.
This variable is used within the Engine module, specifically in the camera stack types implementation. It’s accessed in the CalculateProjectionMatrixGivenViewRectangle function to determine whether to use the legacy method for maintaining Y-FOV.
The value of CVarUseLegacyMaintainYFOV is set when r.UseLegacyMaintainYFOVViewMatrix is set, as they are directly linked.
Developers should be aware that this variable is used in runtime calculations, so changing its value can have immediate effects on the game’s rendering.
Best practices for CVarUseLegacyMaintainYFOV are the same as for r.UseLegacyMaintainYFOVViewMatrix, as they are essentially two sides of the same coin. Any considerations for one apply equally to the other.
#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:11
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarUseLegacyMaintainYFOV(
TEXT("r.UseLegacyMaintainYFOVViewMatrix"),
false,
TEXT("Whether to use the old way to compute perspective view matrices when the aspect ratio constraint is vertical"),
ECVF_Default
);
static TAutoConsoleVariable<bool> CVarOrthoAllowAutoPlanes(
#Associated Variable and Callsites
This variable is associated with another variable named CVarUseLegacyMaintainYFOV
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:10
Scope: file
Source code excerpt:
#include UE_INLINE_GENERATED_CPP_BY_NAME(CameraStackTypes)
static TAutoConsoleVariable<bool> CVarUseLegacyMaintainYFOV(
TEXT("r.UseLegacyMaintainYFOVViewMatrix"),
false,
TEXT("Whether to use the old way to compute perspective view matrices when the aspect ratio constraint is vertical"),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Camera/CameraStackTypes.cpp:278
Scope (from outer to inner):
file
function void FMinimalViewInfo::CalculateProjectionMatrixGivenViewRectangle
Source code excerpt:
float MatrixHalfFOV;
if (!bMaintainXFOV && ViewInfo.AspectRatio != 0.f && !CVarUseLegacyMaintainYFOV.GetValueOnGameThread())
{
// The view-info FOV is horizontal. But if we have a different aspect ratio constraint, we need to
// adjust this FOV value using the aspect ratio it was computed with, so we that we can compute the
// complementary FOV value (with the *effective* aspect ratio) correctly.
const float HalfXFOV = FMath::DegreesToRadians(FMath::Max(0.001f, ViewInfo.FOV) / 2.f);
const float HalfYFOV = FMath::Atan(FMath::Tan(HalfXFOV) / ViewInfo.AspectRatio);