CameraTranslationThreshold

CameraTranslationThreshold

#Overview

name: CameraTranslationThreshold

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CameraTranslationThreshold is to define a distance threshold for camera movement beyond which occlusion queries from the previous frame are ignored. This setting is primarily used in the rendering system of Unreal Engine 5.

This setting variable is mainly relied upon by the Renderer module of Unreal Engine, specifically within the scene visibility and occlusion query systems.

The value of this variable is set in the Engine configuration files. It is defined as a config property in the UEngine class, which means it can be modified through project settings or configuration files.

CameraTranslationThreshold interacts with other variables, particularly:

  1. CameraRotationThreshold: Used together to determine if there’s been a large camera movement.
  2. PrimitiveProbablyVisibleTime: Another occlusion-related setting defined nearby in the Engine class.

Developers must be aware that this variable directly impacts the performance and accuracy of occlusion queries. Setting it too low might cause unnecessary recalculations of occlusion, while setting it too high might result in visual artifacts or incorrect occlusion.

Best practices when using this variable include:

  1. Carefully tuning the value based on the specific needs of your game or application.
  2. Consider the relationship between this value and CameraRotationThreshold for a balanced approach to detecting significant camera movements.
  3. Profile your application’s performance with different values to find the optimal balance between visual quality and performance.
  4. Be mindful of how changes to this value might affect different hardware configurations, especially in terms of performance on lower-end devices.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:285, section: [/Script/Engine.Engine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1639

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	/** camera movement beyond which occlusion queries are ignored from previous frame (because they are likely not valid) */
	UPROPERTY(config)
	float CameraTranslationThreshold;

	/** The amount of time a primitive is considered to be probably visible after it was last actually visible. */
	UPROPERTY(config)
	float PrimitiveProbablyVisibleTime;

	/** Max screen pixel fraction where retesting when unoccluded is worth the GPU time. */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4617

Scope (from outer to inner):

file
function     static bool IsLargeCameraMovement

Source code excerpt:

 * Helper for InitViews to detect large camera movement, in both angle and position.
 */
static bool IsLargeCameraMovement(FSceneView& View, const FMatrix& PrevViewMatrix, const FVector& PrevViewOrigin, float CameraRotationThreshold, float CameraTranslationThreshold)
{
	float RotationThreshold = FMath::Cos(FMath::DegreesToRadians(CameraRotationThreshold));
	float ViewRightAngle = View.ViewMatrices.GetViewMatrix().GetColumn(0) | PrevViewMatrix.GetColumn(0);
	float ViewUpAngle = View.ViewMatrices.GetViewMatrix().GetColumn(1) | PrevViewMatrix.GetColumn(1);
	float ViewDirectionAngle = View.ViewMatrices.GetViewMatrix().GetColumn(2) | PrevViewMatrix.GetColumn(2);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:4629

Scope (from outer to inner):

file
function     static bool IsLargeCameraMovement

Source code excerpt:

		ViewUpAngle < RotationThreshold ||
		ViewDirectionAngle < RotationThreshold ||
		Distance.SizeSquared() > CameraTranslationThreshold * CameraTranslationThreshold;
}

void FSceneRenderer::PreVisibilityFrameSetup(FRDGBuilder& GraphBuilder)
{
	FRHICommandListImmediate& RHICmdList = GraphBuilder.RHICmdList;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneVisibility.cpp:5108

Scope (from outer to inner):

file
function     void FSceneRenderer::PrepareViewStateForVisibility

Source code excerpt:

				    FMatrix(ViewState->PrevViewMatrixForOcclusionQuery), 
				    ViewState->PrevViewOriginForOcclusionQuery, 
				    GEngine->CameraRotationThreshold, GEngine->CameraTranslationThreshold))
			{
				View.bIgnoreExistingQueries = true;
				View.bDisableDistanceBasedFadeTransitions = true;
			}

			// Turn on/off round-robin occlusion querying in the ViewState