r.Ortho.CameraHeightAsViewTarget

r.Ortho.CameraHeightAsViewTarget

#Overview

name: r.Ortho.CameraHeightAsViewTarget

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.CameraHeightAsViewTarget is to control whether the camera height should be used as a pseudo camera-to-view target distance in orthographic projections. This setting is primarily used in the rendering system, specifically for handling orthographic camera views.

This setting variable is relied upon by the Engine module, particularly in the scene view and projection calculations. It’s used within the FSceneViewProjectionData class, which is responsible for managing view projection data.

The value of this variable is set through a console variable (CVarOrthoCameraHeightAsViewTarget) in the Engine’s SceneView.cpp file. It’s initialized with a default value of true, meaning this behavior is enabled by default.

The associated variable CVarOrthoCameraHeightAsViewTarget directly interacts with r.Ortho.CameraHeightAsViewTarget. They share the same value and purpose.

Developers must be aware that this variable affects the calculation of the view origin in orthographic projections. When enabled, it adjusts the view origin based on the camera height, which can impact Virtual Shadow Map (VSM) clipmap selection and near plane calculations.

Best practices when using this variable include:

  1. Consider the impact on shadow rendering, especially when using Virtual Shadow Maps.
  2. Be mindful of how it affects the near plane in orthographic views.
  3. Test thoroughly when changing this setting, as it can affect the visual output of orthographic cameras.

Regarding the associated variable CVarOrthoCameraHeightAsViewTarget:

Its purpose is identical to r.Ortho.CameraHeightAsViewTarget, serving as the actual console variable that controls this setting.

It’s part of the Engine module and is used in the same contexts as r.Ortho.CameraHeightAsViewTarget.

The value is set when the engine initializes the console variables, with a default value of true.

It directly interacts with r.Ortho.CameraHeightAsViewTarget, effectively being the same setting.

Developers should be aware that this is a console variable, meaning it can be changed at runtime through console commands.

Best practices include using this variable for debugging or fine-tuning rendering behavior in orthographic views, and considering its performance implications in different scenarios.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:352

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarOrthoCameraHeightAsViewTarget(
	TEXT("r.Ortho.CameraHeightAsViewTarget"),
	true,
	TEXT("Sets whether to use the camera height as a pseudo camera to view target.\n")
	TEXT("Primarily helps with VSM clipmap selection and avoids overcorrecting NearPlanes.\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

int32 GVirtualTextureFeedbackFactor = 16;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:351

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarOrthoCameraHeightAsViewTarget(
	TEXT("r.Ortho.CameraHeightAsViewTarget"),
	true,
	TEXT("Sets whether to use the camera height as a pseudo camera to view target.\n")
	TEXT("Primarily helps with VSM clipmap selection and avoids overcorrecting NearPlanes.\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:639

Scope (from outer to inner):

file
function     bool FSceneViewProjectionData::UpdateOrthoPlanes

Source code excerpt:

		*/
		float CameraHeightAdjustment = 0.0f;
		if (CVarOrthoCameraHeightAsViewTarget.GetValueOnAnyThread() && bUseCameraHeightAsViewTarget)
		{
			CameraHeightAdjustment = FMath::Abs(FMath::Min(InOutProjectionData->ViewOrigin.Z, HalfOrthoWidth)) * FMath::Abs((ViewForward.Dot(FVector(0, 0, -1.0f))));
		}
		InOutProjectionData->ViewOrigin += ViewForward * (CameraHeightAdjustment + NearPlane);
	}
	NearPlane = GDefaultUpdateOrthoNearPlane;