r.MotionBlurScatter

r.MotionBlurScatter

#Overview

name: r.MotionBlurScatter

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.MotionBlurScatter is to control the motion blur rendering technique in Unreal Engine 5. Specifically, it forces the use of a scatter-based maximum velocity method for motion blur, which is slower but potentially higher quality.

This setting variable is primarily used in the rendering system, specifically within the post-processing pipeline for motion blur effects. It is part of the Renderer module in Unreal Engine.

The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime. It is initialized with a default value of 0, meaning the scatter-based method is not forced by default.

The associated variable CVarMotionBlurScatter directly interacts with r.MotionBlurScatter. They share the same value and purpose.

Developers should be aware that:

  1. Enabling this setting (setting it to 1) will force the use of a slower, but potentially higher quality motion blur method.
  2. This setting is render thread safe, meaning it can be changed without causing threading issues in the rendering pipeline.
  3. It’s particularly useful for cinematic scenes where higher quality motion blur is desired.

Best practices when using this variable include:

  1. Only enable it when higher quality motion blur is necessary, as it comes with a performance cost.
  2. Consider enabling it for cinematic sequences or other scenarios where visual quality is prioritized over performance.
  3. Test the performance impact in your specific use case before enabling it globally.

Regarding the associated variable CVarMotionBlurScatter:

The purpose of CVarMotionBlurScatter is to provide programmatic access to the r.MotionBlurScatter setting within the C++ code of the engine.

It is used in the Renderer module, specifically in the motion blur post-processing code.

The value of CVarMotionBlurScatter is set when the r.MotionBlurScatter console variable is changed, either through console commands or configuration files.

CVarMotionBlurScatter interacts directly with the r.MotionBlurScatter setting, effectively serving as its in-code representation.

Developers should be aware that:

  1. Changes to CVarMotionBlurScatter will affect the motion blur rendering immediately.
  2. It’s used in conditional logic to determine whether to use the scatter-based method.

Best practices for using CVarMotionBlurScatter include:

  1. Use GetValueOnRenderThread() when accessing its value in render thread code.
  2. Be cautious about changing its value frequently, as it could impact performance.
  3. Consider the context (e.g., cinematic vs. gameplay) when deciding whether to enable it.

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	TAutoConsoleVariable<int32> CVarMotionBlurScatter(
		TEXT("r.MotionBlurScatter"),
		0,
		TEXT("Forces scatter based max velocity method (slower)."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurSeparable(
		TEXT("r.MotionBlurSeparable"),

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

		ECVF_Cheat | ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurScatter(
		TEXT("r.MotionBlurScatter"),
		0,
		TEXT("Forces scatter based max velocity method (slower)."),
		ECVF_RenderThreadSafe);

	TAutoConsoleVariable<int32> CVarMotionBlurSeparable(

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

Scope (from outer to inner):

file
function     bool IsMotionBlurScatterRequired

Source code excerpt:


	// Use the scatter approach if requested by cvar or we're in a paused cinematic (higher quality).
	const bool bIsScatterRequiredByUser = CVarMotionBlurScatter.GetValueOnRenderThread() == 1 || bInPausedCinematic;

	return bIsScatterRequiredByUser || bIsScatterRequiredByVelocityLength;
}

FIntPoint GetMotionBlurTileCount(FIntPoint SizeInPixels)
{