r.MotionBlur2ndScale
r.MotionBlur2ndScale
#Overview
name: r.MotionBlur2ndScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MotionBlur2ndScale is to control the scaling of the second pass in the motion blur effect within Unreal Engine’s rendering system. This setting variable is used to fine-tune the intensity of the motion blur effect.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the post-processing component responsible for motion blur. 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. It’s initialized with a default value of 1.0f, but can be changed at runtime using console commands or through engine configuration files.
The associated variable CVarMotionBlur2ndScale interacts directly with r.MotionBlur2ndScale. They share the same value and purpose. CVarMotionBlur2ndScale is the actual console variable object that holds the value, while r.MotionBlur2ndScale is the string used to reference this variable in console commands or configuration files.
Developers must be aware that this variable is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags. The ECVF_Cheat flag indicates that this variable should not be modifiable in shipping builds, while ECVF_RenderThreadSafe means it can be safely modified from the render thread.
Best practices when using this variable include:
- Use it for fine-tuning the motion blur effect during development and testing.
- Be cautious about changing its value in shipping builds, as it’s marked as a cheat variable.
- Consider the performance implications of adjusting this value, as it affects the intensity of a post-processing effect.
- Test thoroughly across different hardware configurations to ensure the chosen value provides a good balance between visual quality and performance.
Regarding the associated variable CVarMotionBlur2ndScale: The purpose of CVarMotionBlur2ndScale is to provide programmatic access to the r.MotionBlur2ndScale setting within the C++ code of the engine. It’s used to retrieve the current value of the setting in the render thread, as seen in the second code excerpt where GetValueOnRenderThread() is called.
This variable is part of the console variable system in Unreal Engine, which allows for runtime configuration of engine parameters. It’s defined as a TAutoConsoleVariable
The value of CVarMotionBlur2ndScale is set when the r.MotionBlur2ndScale console command is used or when the corresponding entry in a configuration file is processed.
Developers should be aware that changes to this variable will directly affect the motion blur rendering process. It’s used in the FMotionBlurVelocityFlattenCS class, which is likely part of the motion blur computation shader.
Best practices for using CVarMotionBlur2ndScale include:
- Access its value using GetValueOnRenderThread() when in render thread code.
- Consider caching the value if it’s used frequently in performance-critical sections.
- Be aware of its impact on the motion blur effect and adjust it carefully to maintain the desired visual quality.
#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:24
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<float> CVarMotionBlur2ndScale(
TEXT("r.MotionBlur2ndScale"),
1.0f,
TEXT(""),
ECVF_Cheat | ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarMotionBlurScatter(
TEXT("r.MotionBlurScatter"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMotionBlur2ndScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:23
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
#endif
TAutoConsoleVariable<float> CVarMotionBlur2ndScale(
TEXT("r.MotionBlur2ndScale"),
1.0f,
TEXT(""),
ECVF_Cheat | ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarMotionBlurScatter(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:829
Scope (from outer to inner):
file
class class FMotionBlurVelocityFlattenCS : public FMotionBlurShader
Source code excerpt:
const int32 BlurDirections = GetMotionBlurDirections();
const float MotionBlur2ndScale = CVarMotionBlur2ndScale.GetValueOnRenderThread();
const bool bUseCompute = View.bUseComputePasses;
const float BlurScaleLUT[static_cast<uint32>(EMotionBlurFilterPass::MAX)][static_cast<uint32>(EMotionBlurQuality::MAX)] =
{
// Separable0