r.Test.ForceBlackVelocityBuffer
r.Test.ForceBlackVelocityBuffer
#Overview
name: r.Test.ForceBlackVelocityBuffer
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Force the velocity buffer to have no motion vector for debugging purpose.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Test.ForceBlackVelocityBuffer is to force the velocity buffer to have no motion vector for debugging purposes in the rendering system. This setting variable is part of Unreal Engine’s rendering subsystem and is specifically used for testing and debugging scenarios related to motion vectors and velocity buffers.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its presence in the DeferredShadingRenderer.cpp file.
The value of this variable is set through the console variable system. It is defined as a TAutoConsoleVariable with an initial value of 0, which means it’s disabled by default.
This variable interacts directly with its associated variable CVarForceBlackVelocityBuffer. They share the same value and purpose.
Developers must be aware that:
- This variable is only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
- It’s intended for debugging purposes and should not be used in production environments.
- When enabled, it forces the velocity buffer to be black, effectively removing all motion vectors.
Best practices when using this variable include:
- Only use it for debugging motion vector-related issues.
- Remember to disable it after debugging to restore normal motion vector functionality.
- Be cautious when using it in complex scenes, as it may affect other systems that rely on motion vectors.
Regarding the associated variable CVarForceBlackVelocityBuffer:
The purpose of CVarForceBlackVelocityBuffer is identical to r.Test.ForceBlackVelocityBuffer. It’s the actual console variable that controls the functionality.
This variable is used within the FDeferredShadingSceneRenderer::Render function to modify the scene textures. When enabled, it replaces the Velocity texture with a black texture and rebuilds the scene texture uniform buffer.
Developers should be aware that:
- This variable is checked on the render thread (GetValueOnRenderThread()).
- Enabling it will affect the entire scene’s motion vectors, which could impact various visual effects and post-processing.
Best practices for using CVarForceBlackVelocityBuffer are the same as those for r.Test.ForceBlackVelocityBuffer, as they are effectively the same variable used in different contexts within the engine’s code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:231
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarForceBlackVelocityBuffer(
TEXT("r.Test.ForceBlackVelocityBuffer"), 0,
TEXT("Force the velocity buffer to have no motion vector for debugging purpose."),
ECVF_RenderThreadSafe);
#endif
static TAutoConsoleVariable<int32> CVarNaniteViewMeshLODBiasEnable(
TEXT("r.Nanite.ViewMeshLODBias.Enable"), 1,
#Associated Variable and Callsites
This variable is associated with another variable named CVarForceBlackVelocityBuffer
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:230
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarForceBlackVelocityBuffer(
TEXT("r.Test.ForceBlackVelocityBuffer"), 0,
TEXT("Force the velocity buffer to have no motion vector for debugging purpose."),
ECVF_RenderThreadSafe);
#endif
static TAutoConsoleVariable<int32> CVarNaniteViewMeshLODBiasEnable(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:3134
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::Render
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (CVarForceBlackVelocityBuffer.GetValueOnRenderThread())
{
SceneTextures.Velocity = SystemTextures.Black;
// Rebuild the scene texture uniform buffer to include black.
SceneTextures.UniformBuffer = CreateSceneTextureUniformBuffer(GraphBuilder, &SceneTextures, FeatureLevel, SceneTextures.SetupMode);
}