ShowFlag.VisualizeMotionVectors
ShowFlag.VisualizeMotionVectors
#Overview
name: ShowFlag.VisualizeMotionVectors
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 9
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.VisualizeMotionVectors is to enable visualization of motion vectors in the rendering pipeline. Motion vectors represent the movement of pixels between frames and are used for various effects like motion blur and temporal anti-aliasing.
Key points about ShowFlag.VisualizeMotionVectors:
-
It’s part of the rendering system, specifically for debugging and visualizing motion vectors.
-
It’s used in the post-processing passes of Unreal Engine’s renderer.
-
The flag is checked in the AddPostProcessingPasses function to determine if the motion vector visualization pass should be added.
-
When enabled, it triggers the AddVisualizeMotionVectorsPass, which creates a visualization of the motion vectors.
-
The visualization uses the current frame’s scene color, depth, and velocity information to create the visual output.
-
It also uses the previous frame’s visualization for comparison and reprojection verification.
-
The result is stored for use in the next frame, allowing frame-to-frame comparison.
-
This flag is often used in conjunction with EngineShowFlags.VisualizeReprojection.
-
It’s primarily a debugging tool and not intended for use in final builds.
Best practices:
- Use this flag during development to debug motion-related rendering issues.
- Be aware that enabling this visualization may impact performance.
- Disable this flag for final builds or performance testing.
- Use in combination with other visualization tools to get a complete picture of the rendering process.
The associated variable VisualizeMotionVectors is used to store the rendered visualization texture from the previous frame. This allows for frame-to-frame comparison and verification of motion vector accuracy. It’s important to manage this resource properly to avoid memory leaks or unnecessary GPU memory usage.
Developers should be aware that this visualization is a debugging tool and may not always accurately represent the final rendered result, especially when other post-processing effects are applied.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:121
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeMotionBlur, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeMotionBlurSF", "Motion Blur"))
/** DEPRECATED in 5.2: Use VisualizeReprojection instead. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeMotionVectors, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeMotionVectorsSF", "Motion Vectors"))
/** Helper to ensure previous frame's temporal history reprojections using motion vectors are working correctly. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeReprojection, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeReprojectionSF", "Previous frame's reprojection"))
/** Helper to diagnose temporal upscaler's inputs and outputs. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeTemporalUpscaler, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeTemporalUpscalerSF", "Temporal Upscaler I/O (TSR, TAAU or third party plugins)"))
/** Helper to diagnose the internals of TSR. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeTSR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeTSRSF", "Temporal Super Resolution"))
#Associated Variable and Callsites
This variable is associated with another variable named VisualizeMotionVectors
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:121
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeMotionBlur, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeMotionBlurSF", "Motion Blur"))
/** DEPRECATED in 5.2: Use VisualizeReprojection instead. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeMotionVectors, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeMotionVectorsSF", "Motion Vectors"))
/** Helper to ensure previous frame's temporal history reprojections using motion vectors are working correctly. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeReprojection, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeReprojectionSF", "Previous frame's reprojection"))
/** Helper to diagnose temporal upscaler's inputs and outputs. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeTemporalUpscaler, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeTemporalUpscalerSF", "Temporal Upscaler I/O (TSR, TAAU or third party plugins)"))
/** Helper to diagnose the internals of TSR. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeTSR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeTSRSF", "Temporal Super Resolution"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:386
Scope (from outer to inner):
file
function void AddPostProcessingPasses
Source code excerpt:
VisualizeHDR,
VisualizeLocalExposure,
VisualizeMotionVectors,
VisualizeTemporalUpscaler,
PixelInspector,
HMDDistortion,
HighResolutionScreenshotMask,
#if UE_ENABLE_DEBUG_DRAWING
DebugPrimitive,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:489
Scope (from outer to inner):
file
function void AddPostProcessingPasses
Source code excerpt:
PassSequence.SetEnabled(EPass::VisualizeLumenSceneOverview, (LumenVisualizeMode == VISUALIZE_MODE_OVERVIEW || LumenVisualizeMode == VISUALIZE_MODE_PERFORMANCE_OVERVIEW) && bPostProcessingEnabled);
PassSequence.SetEnabled(EPass::VisualizeHDR, EngineShowFlags.VisualizeHDR);
PassSequence.SetEnabled(EPass::VisualizeMotionVectors, EngineShowFlags.VisualizeMotionVectors || EngineShowFlags.VisualizeReprojection);
PassSequence.SetEnabled(EPass::VisualizeTemporalUpscaler, EngineShowFlags.VisualizeTemporalUpscaler);
#if WITH_EDITOR
PassSequence.SetEnabled(EPass::PixelInspector, View.bUsePixelInspector);
#else
PassSequence.SetEnabled(EPass::PixelInspector, false);
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:1612
Scope (from outer to inner):
file
function void AddPostProcessingPasses
Source code excerpt:
}
if (PassSequence.IsEnabled(EPass::VisualizeMotionVectors))
{
FVisualizeMotionVectorsInputs PassInputs;
PassSequence.AcceptOverrideIfLastPass(EPass::VisualizeMotionVectors, PassInputs.OverrideOutput);
PassInputs.SceneColor = SceneColor;
PassInputs.SceneDepth = SceneDepth;
PassInputs.SceneVelocity = Velocity;
SceneColor = AddVisualizeMotionVectorsPass(GraphBuilder, View, PassInputs, EVisualizeMotionVectors::ReprojectionAlignment);
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/VisualizeMotionVectors.cpp:48
Scope (from outer to inner):
file
function FScreenPassTexture AddVisualizeMotionVectorsPass
Source code excerpt:
FScreenPassTexture PrevColor;
if (View.PrevViewInfo.VisualizeMotionVectors.IsValid())
{
PrevColor.Texture = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.VisualizeMotionVectors);
PrevColor.ViewRect = View.PrevViewInfo.VisualizeMotionVectorsRect;
}
else
{
PrevColor.Texture = GSystemTextures.GetBlackDummy(GraphBuilder);
PrevColor.ViewRect = FIntRect(0, 0, 1, 1);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/VisualizeMotionVectors.cpp:111
Scope (from outer to inner):
file
function FScreenPassTexture AddVisualizeMotionVectorsPass
Source code excerpt:
if (View.ViewState && !View.bStatePrevViewInfoIsReadOnly)
{
GraphBuilder.QueueTextureExtraction(Inputs.SceneColor.Texture, &View.ViewState->PrevFrameViewInfo.VisualizeMotionVectors);
View.ViewState->PrevFrameViewInfo.VisualizeMotionVectorsRect = Inputs.SceneColor.ViewRect;
}
return MoveTemp(Output);
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:891
Scope (from outer to inner):
file
function uint64 FPreviousViewInfo::GetGPUSizeBytes
Source code excerpt:
GetRenderTargetGPUSizeBytes(MobilePixelProjectedReflection, bLogSizes) +
GetRenderTargetGPUSizeBytes(MobileAmbientOcclusion, bLogSizes) +
GetRenderTargetGPUSizeBytes(VisualizeMotionVectors, bLogSizes);
for (auto ShadowHistoryIt = ShadowHistories.begin(); ShadowHistoryIt; ++ShadowHistoryIt)
{
if (ShadowHistoryIt.Value().IsValid())
{
TotalSize += ShadowHistoryIt.Value()->GetGPUSizeBytes(bLogSizes);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:1163
Scope: file
Source code excerpt:
// Scene color used for reprojecting next frame to verify the motion vector reprojects correctly.
TRefCountPtr<IPooledRenderTarget> VisualizeMotionVectors;
FIntRect VisualizeMotionVectorsRect;
uint64 GetGPUSizeBytes(bool bLogSizes) const;
};
#if RHI_RAYTRACING