r.Velocity.ForceOutput

r.Velocity.ForceOutput

#Overview

name: r.Velocity.ForceOutput

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Velocity.ForceOutput is to force velocity output on all primitives in the rendering system of Unreal Engine 5. This setting is primarily used for testing and debugging purposes, particularly when velocity output isn’t being enabled as expected.

This setting variable is utilized by the rendering subsystem of Unreal Engine, specifically within the PrimitiveSceneProxy component. It’s part of the Engine module, as evidenced by its location in the Engine/Source/Runtime/Engine directory.

The value of this variable is set through a console command. It’s defined as a TAutoConsoleVariable with an initial value of 0 (disabled by default).

The associated variable CVarVelocityForceOutput directly interacts with r.Velocity.ForceOutput. They share the same value and are used interchangeably in the code.

Developers must be aware that enabling this setting can incur a performance cost unless r.VelocityOutputPass=1 is also set. It’s primarily intended for testing and debugging, not for general use in production environments.

Best practices for using this variable include:

  1. Only enable it when necessary for debugging velocity output issues.
  2. Consider the performance implications, especially if r.VelocityOutputPass is not set to 1.
  3. Disable it when not actively debugging to avoid unnecessary performance overhead.
  4. Use in conjunction with other velocity-related settings for comprehensive testing.

Regarding the associated variable CVarVelocityForceOutput:

The purpose of CVarVelocityForceOutput is to provide a programmatic interface to the r.Velocity.ForceOutput setting within the C++ code of Unreal Engine.

It’s used in the same Engine subsystem, specifically within the PrimitiveSceneProxy component.

The value is set when the console variable is initialized, and it can be accessed using the GetValueOnAnyThread() method.

This variable directly affects the bAlwaysHasVelocity flag in the FPrimitiveSceneProxy class, which determines whether velocity output is forced for all primitives.

Developers should be aware that changes to this variable will immediately affect the rendering behavior of all primitives in the scene.

Best practices include using this variable for programmatic control of velocity output forcing, especially in scenarios where dynamic adjustment of this setting is required during runtime.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:76

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVelocityForceOutput(
	TEXT("r.Velocity.ForceOutput"), 0,
	TEXT("Force velocity output on all primitives.\n")
	TEXT("This can incur a performance cost unless r.VelocityOutputPass=1.\n")
	TEXT("But it can be useful for testing where velocity output isn't being enabled as expected.\n")
	TEXT("0: Disabled (default)\n")
	TEXT("1: Enabled"),
	FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:75

Scope: file

Source code excerpt:

	);

static TAutoConsoleVariable<int32> CVarVelocityForceOutput(
	TEXT("r.Velocity.ForceOutput"), 0,
	TEXT("Force velocity output on all primitives.\n")
	TEXT("This can incur a performance cost unless r.VelocityOutputPass=1.\n")
	TEXT("But it can be useful for testing where velocity output isn't being enabled as expected.\n")
	TEXT("0: Disabled (default)\n")
	TEXT("1: Enabled"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:666

Scope: file

Source code excerpt:

	}

	bAlwaysHasVelocity = CVarVelocityForceOutput.GetValueOnAnyThread();
	if (!bAlwaysHasVelocity && InProxyDesc.SupportsWorldPositionOffsetVelocity() && VertexDeformationOutputsVelocity() && bAnyMaterialHasWorldPositionOffset)
	{
		bHasWorldPositionOffsetVelocity = true;
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:924

Scope (from outer to inner):

file
function     void FPrimitiveSceneProxy::UpdateInstances_RenderThread

Source code excerpt:

	LocalBounds = InLocalBounds;

	bAlwaysHasVelocity = CVarVelocityForceOutput.GetValueOnAnyThread() ||  GetInstanceDataHeader().Flags.bHasPerInstanceDynamicData;
}

bool FPrimitiveSceneProxy::WouldSetTransformBeRedundant_AnyThread(const FMatrix& InLocalToWorld, const FBoxSphereBounds& InBounds, const FBoxSphereBounds& InLocalBounds, const FVector& InActorPosition) const
{
	// Order is based on cheapest tests first.
	// Actor position checks if the actor has moved in the world, and local bounds