r.MotionBlurSeparable

r.MotionBlurSeparable

#Overview

name: r.MotionBlurSeparable

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.MotionBlurSeparable is to control whether a second motion blur pass is added to smooth out noise and achieve a higher quality blur in the rendering process.

This setting variable is primarily used in the rendering system of Unreal Engine 5, specifically in the post-processing pipeline for motion blur effects. Based on the callsites, it’s part of the Renderer module, located in the PostProcessMotionBlur.cpp file.

The value of this variable is set through a console variable (CVarMotionBlurSeparable) with a default value of 0. It can be changed at runtime using console commands or through project settings.

The associated variable CVarMotionBlurSeparable directly interacts with r.MotionBlurSeparable. They share the same value and purpose.

Developers should be aware that enabling this variable (setting it to a non-zero value) will add computational overhead due to the additional motion blur pass. This may impact performance, especially on lower-end hardware.

Best practices when using this variable include:

  1. Testing the visual quality improvement versus the performance impact.
  2. Considering the target hardware when deciding whether to enable this feature.
  3. Using it in conjunction with other motion blur settings for optimal results.

Regarding the associated variable CVarMotionBlurSeparable:

The purpose of CVarMotionBlurSeparable is to provide a programmatic way to access and modify the r.MotionBlurSeparable setting within the engine’s C++ code.

This variable is used in the Renderer module, specifically in the motion blur post-processing logic. It’s accessed in the GetMotionBlurFilter() function to determine which motion blur filter to use.

The value of CVarMotionBlurSeparable is set when the console variable is initialized, but can be changed at runtime through console commands or engine API calls.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is important for thread safety in multi-threaded rendering scenarios.

Best practices for using CVarMotionBlurSeparable include:

  1. Accessing its value on the correct thread (render thread in this case).
  2. Considering caching the value if it’s accessed frequently, to avoid potential performance overhead from repeated calls to GetValueOnRenderThread().
  3. Using it in conjunction with other motion blur settings for a cohesive motion blur implementation.

#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:36

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarMotionBlurSeparable(
		TEXT("r.MotionBlurSeparable"),
		0,
		TEXT("Adds a second motion blur pass that smooths noise for a higher quality blur."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurDirections(
		TEXT("r.MotionBlur.Directions"),

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurSeparable(
		TEXT("r.MotionBlurSeparable"),
		0,
		TEXT("Adds a second motion blur pass that smooths noise for a higher quality blur."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurDirections(

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

Scope (from outer to inner):

file
function     EMotionBlurFilter GetMotionBlurFilter

Source code excerpt:

EMotionBlurFilter GetMotionBlurFilter()
{
	return CVarMotionBlurSeparable.GetValueOnRenderThread() != 0 ? EMotionBlurFilter::Separable : EMotionBlurFilter::Unified;
}

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