r.MotionBlurFiltering

r.MotionBlurFiltering

#Overview

name: r.MotionBlurFiltering

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.MotionBlurFiltering is to control the filtering applied to motion blur in the rendering system. It is a developer-oriented variable used for debugging and testing purposes in the motion blur post-processing effect.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the post-processing system for motion blur. It is referenced in the PostProcessMotionBlur.cpp file, which is part of the motion blur implementation.

The value of this variable is set through a console variable (CVarMotionBlurFiltering) using the TAutoConsoleVariable class. It is initialized with a default value of 0, meaning the filtering is off by default.

The associated variable CVarMotionBlurFiltering directly interacts with r.MotionBlurFiltering. They share the same value and purpose.

Developers must be aware of several important aspects when using this variable:

  1. It is only available in non-shipping and non-test builds (defined by the preprocessor condition #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)).
  2. It is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags, indicating it’s a cheat command and safe to use on the render thread.
  3. The default value (0) is expected by the shader for better quality, as mentioned in the description.

Best practices when using this variable include:

  1. Use it only for development and debugging purposes, not in production builds.
  2. Be cautious when enabling it (setting to 1) as it may impact the visual quality of motion blur.
  3. When testing motion blur quality, compare results with this variable set to 0 and 1 to understand its impact.

Regarding the associated variable CVarMotionBlurFiltering:

The purpose of CVarMotionBlurFiltering is to provide a runtime-accessible way to toggle the motion blur filtering. It is used to actually implement the functionality controlled by r.MotionBlurFiltering.

This variable is used in the Renderer module, specifically in the motion blur post-processing effect. It’s defined and used in the same file as r.MotionBlurFiltering (PostProcessMotionBlur.cpp).

The value of CVarMotionBlurFiltering is set when it’s created using TAutoConsoleVariable, with the same default value and description as r.MotionBlurFiltering.

CVarMotionBlurFiltering directly interacts with the motion blur rendering code. It’s used to determine whether to apply filtering in the GetMotionBlurColorSampler function.

Developers should be aware that:

  1. This variable is only available in development builds.
  2. Changes to this variable will affect the motion blur rendering in real-time.

Best practices for using CVarMotionBlurFiltering include:

  1. Use GetValueOnRenderThread() to access its value safely from the render thread.
  2. Consider the performance implications when enabling filtering, as it may impact render times.
  3. Use this variable in conjunction with other motion blur debugging tools for comprehensive testing and optimization.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	TAutoConsoleVariable<int32> CVarMotionBlurFiltering(
		TEXT("r.MotionBlurFiltering"),
		0,
		TEXT("Useful developer variable\n")
		TEXT("0: off (default, expected by the shader for better quality)\n")
		TEXT("1: on"),
		ECVF_Cheat | ECVF_RenderThreadSafe);
#endif

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	TAutoConsoleVariable<int32> CVarMotionBlurFiltering(
		TEXT("r.MotionBlurFiltering"),
		0,
		TEXT("Useful developer variable\n")
		TEXT("0: off (default, expected by the shader for better quality)\n")
		TEXT("1: on"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
function     FRHISamplerState* GetMotionBlurColorSampler

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	bFiltered = CVarMotionBlurFiltering.GetValueOnRenderThread() != 0;
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

	if (bFiltered)
	{
		return TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();
	}