r.MotionBlur.Directions

r.MotionBlur.Directions

#Overview

name: r.MotionBlur.Directions

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.MotionBlur.Directions is to control the number of blurring directions in the motion blur effect for the rendering system. This setting variable is part of Unreal Engine’s post-processing pipeline, specifically the motion blur implementation.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the post-processing component responsible for motion blur effects. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp.

The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s initialized with a default value of 1, meaning one blurring direction by default.

This variable interacts with an associated variable named CVarMotionBlurDirections. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the quality and performance of the motion blur effect. Increasing the number of directions can potentially improve the visual quality of the motion blur but may also increase the computational cost.

Best practices when using this variable include:

  1. Keeping the value low (1 or 2) for performance-critical scenarios.
  2. Testing different values to find the right balance between visual quality and performance for your specific use case.
  3. Being cautious when modifying this value at runtime, as it can affect frame rate.

Regarding the associated variable CVarMotionBlurDirections:

This is the actual console variable that stores and provides access to the r.MotionBlur.Directions value. It’s defined as a TAutoConsoleVariable, which means it’s an integer value that can be modified through the console or configuration files.

The GetMotionBlurDirections() function uses this variable to retrieve the current value, clamping it between 1 and 2. This suggests that while the variable itself doesn’t have hard limits, the implementation only supports 1 or 2 directions.

When working with CVarMotionBlurDirections, developers should:

  1. Use the GetValueOnRenderThread() method to access its value safely from the render thread.
  2. Be aware of the clamping behavior in GetMotionBlurDirections() when setting values.
  3. Consider the performance implications when changing this value, especially in performance-critical sections of the code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:42

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarMotionBlurDirections(
		TEXT("r.MotionBlur.Directions"),
		1,
		TEXT("Number of bluring direction (default = 1)."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurHalfResInput(
		TEXT("r.MotionBlur.HalfResInput"), 1,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:41

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurDirections(
		TEXT("r.MotionBlur.Directions"),
		1,
		TEXT("Number of bluring direction (default = 1)."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurHalfResInput(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:180

Scope (from outer to inner):

file
function     int32 GetMotionBlurDirections

Source code excerpt:

int32 GetMotionBlurDirections()
{
	return FMath::Clamp(CVarMotionBlurDirections.GetValueOnRenderThread(), 1, 2);
}

// static
bool FVelocityFlattenTextures::AllowExternal(const FViewInfo& View)
{
	const bool bEnableCameraMotionBlur = View.bCameraMotionBlur.Get(true);