CameraRotationThreshold

CameraRotationThreshold

#Overview

name: CameraRotationThreshold

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 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CameraRotationThreshold is to define a threshold for camera rotation, beyond which occlusion queries from the previous frame are ignored. This setting is primarily used in the rendering system of Unreal Engine 5, specifically for optimizing occlusion culling.

Based on the provided callsites, this variable is used in the Renderer module of Unreal Engine, particularly in the scene visibility and occlusion culling systems.

The value of this variable is set in the engine configuration files, as indicated by the UPROPERTY(config) decorator in the UEngine class definition.

CameraRotationThreshold interacts closely with another variable called CameraTranslationThreshold. Both are used together to determine when camera movement is considered large enough to invalidate previous frame’s occlusion queries.

Developers must be aware that this variable affects the performance and accuracy of occlusion culling. Setting it too low might cause unnecessary recalculations of occlusion, while setting it too high might result in visual artifacts due to using outdated occlusion information.

Best practices when using this variable include:

  1. Carefully tuning its value based on the specific needs of your game or application. The optimal value may depend on factors like camera movement speed and scene complexity.
  2. Testing thoroughly with different camera movements to ensure no visual artifacts occur.
  3. Considering the relationship between this variable and CameraTranslationThreshold, as they work together to determine when to ignore previous frame’s occlusion queries.
  4. Monitoring performance metrics related to occlusion culling when adjusting this value to find the best balance between performance and visual quality.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:284, 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:1635

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

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

	/** 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. */

#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);

	FVector Distance = FVector(View.ViewMatrices.GetViewOrigin()) - PrevViewOrigin;
	return 

#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