vr.AllowMotionBlurInVR
vr.AllowMotionBlurInVR
#Overview
name: vr.AllowMotionBlurInVR
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
For projects with motion blur enabled, this allows motion blur to be enabled even while in VR.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of vr.AllowMotionBlurInVR is to control whether motion blur is enabled in virtual reality (VR) environments. It is primarily used in the rendering system, specifically for post-processing effects.
This setting variable is mainly utilized by the Renderer module and the XRBase plugin. The Renderer module uses it to determine if motion blur should be applied in VR scenarios, while the XRBase plugin uses it to set up the view family for XR cameras.
The value of this variable is set through the console variable system. It is initialized with a default value of 0 (disabled) in the PostProcessMotionBlur.cpp file.
The associated variable CVarAllowMotionBlurInVR interacts directly with vr.AllowMotionBlurInVR. It’s used to retrieve the current value of the setting and apply it in various parts of the engine.
Developers must be aware that enabling motion blur in VR can potentially cause discomfort for some users due to increased perceived motion. It’s generally recommended to keep this setting disabled for VR applications unless there’s a specific artistic or technical reason to enable it.
Best practices when using this variable include:
- Keeping it disabled by default for VR projects.
- If enabled, thoroughly testing the VR experience to ensure it doesn’t cause discomfort.
- Providing an in-game option for users to toggle this setting if it’s enabled.
Regarding the associated variable CVarAllowMotionBlurInVR:
- Its purpose is to provide a programmatic way to access and modify the vr.AllowMotionBlurInVR setting.
- It’s used in the XRBase plugin and the Renderer module to check the current state of the setting.
- The value is set through the console variable system, mirroring vr.AllowMotionBlurInVR.
- It interacts directly with vr.AllowMotionBlurInVR, essentially serving as its C++ representation.
- Developers should use this variable when they need to programmatically check or modify the motion blur in VR setting.
- Best practices include caching the variable for performance reasons if it’s accessed frequently, and ensuring any modifications are thread-safe if accessed from multiple threads.
#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:63
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
TAutoConsoleVariable<int32> CVarAllowMotionBlurInVR(
TEXT("vr.AllowMotionBlurInVR"),
0,
TEXT("For projects with motion blur enabled, this allows motion blur to be enabled even while in VR."));
FMatrix GetPreviousWorldToClipMatrix(const FViewInfo& View)
{
if (View.Family->EngineShowFlags.CameraInterpolation)
#Loc: <Workspace>/Engine/Plugins/Runtime/XRBase/Source/XRBase/Private/DefaultXRCamera.cpp:210
Scope (from outer to inner):
file
function void FDefaultXRCamera::SetupViewFamily
Source code excerpt:
void FDefaultXRCamera::SetupViewFamily(FSceneViewFamily& InViewFamily)
{
static const auto CVarAllowMotionBlurInVR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("vr.AllowMotionBlurInVR"));
const bool AllowMotionBlur = (CVarAllowMotionBlurInVR && CVarAllowMotionBlurInVR->GetValueOnAnyThread() != 0);
const IHeadMountedDisplay* const HMD = TrackingSystem->GetHMDDevice();
InViewFamily.EngineShowFlags.MotionBlur = AllowMotionBlur;
if (InViewFamily.Views.Num() > 0 && !InViewFamily.Views[0]->bIsSceneCapture)
{
InViewFamily.EngineShowFlags.HMDDistortion = HMD != nullptr ? HMD->GetHMDDistortionEnabled(InViewFamily.Scene->GetShadingPath()) : false;
#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayCluster/Private/Game/EngineClasses/Basics/DisplayClusterViewportClient.cpp:379
Scope (from outer to inner):
file
function void UDisplayClusterViewportClient::Init
Source code excerpt:
}
// vr.AllowMotionBlurInVR
IConsoleVariable* const AllowMotionBlurInVR = IConsoleManager::Get().FindConsoleVariable(TEXT("vr.AllowMotionBlurInVR"));
if (AllowMotionBlurInVR)
{
AllowMotionBlurInVR->Set(int32(1));
}
// Replace FApp::HasFocus to avoid stalls observed in some render nodes.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1480
Scope (from outer to inner):
file
function bool IsUsingBasePassVelocity
Source code excerpt:
static FShaderPlatformCachedIniValue<int32> PerPlatformCVar(TEXT("r.VelocityOutputPass"));
// Writing velocity in base pass is disabled for desktop forward because it may use MSAA (runtime-settable setting) and Velocity isn't a multisample texture.
// TSR or vr.AllowMotionBlurInVR=1 case aren't recommended for Desktop Forward renderer, and if enabled, cause a separate Velocity pass.
if (IsMobilePlatform(Platform) || IsForwardShadingEnabled(Platform))
{
return false;
}
else
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarAllowMotionBlurInVR
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Runtime/XRBase/Source/XRBase/Private/DefaultXRCamera.cpp:210
Scope (from outer to inner):
file
function void FDefaultXRCamera::SetupViewFamily
Source code excerpt:
void FDefaultXRCamera::SetupViewFamily(FSceneViewFamily& InViewFamily)
{
static const auto CVarAllowMotionBlurInVR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("vr.AllowMotionBlurInVR"));
const bool AllowMotionBlur = (CVarAllowMotionBlurInVR && CVarAllowMotionBlurInVR->GetValueOnAnyThread() != 0);
const IHeadMountedDisplay* const HMD = TrackingSystem->GetHMDDevice();
InViewFamily.EngineShowFlags.MotionBlur = AllowMotionBlur;
if (InViewFamily.Views.Num() > 0 && !InViewFamily.Views[0]->bIsSceneCapture)
{
InViewFamily.EngineShowFlags.HMDDistortion = HMD != nullptr ? HMD->GetHMDDistortionEnabled(InViewFamily.Scene->GetShadingPath()) : false;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:62
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarAllowMotionBlurInVR(
TEXT("vr.AllowMotionBlurInVR"),
0,
TEXT("For projects with motion blur enabled, this allows motion blur to be enabled even while in VR."));
FMatrix GetPreviousWorldToClipMatrix(const FViewInfo& View)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessMotionBlur.cpp:119
Scope (from outer to inner):
file
function bool IsMotionBlurEnabled
Source code excerpt:
&& ViewFamily.bRealtimeUpdate
&& MotionBlurQuality > 0
&& (CVarAllowMotionBlurInVR->GetInt() != 0 || !GEngine->StereoRenderingDevice.IsValid() || !GEngine->StereoRenderingDevice->IsStereoEnabled());
}
bool IsVisualizeMotionBlurEnabled(const FViewInfo& View)
{
return View.Family->EngineShowFlags.VisualizeMotionBlur && View.GetFeatureLevel() >= ERHIFeatureLevel::SM5;
}