vr.AllowMotionBlurInVR

vr.AllowMotionBlurInVR

#Overview

name: vr.AllowMotionBlurInVR

This variable is created as a Console Variable (cvar).

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:

  1. Keeping it disabled by default for VR projects.
  2. If enabled, thoroughly testing the VR experience to ensure it doesn’t cause discomfort.
  3. Providing an in-game option for users to toggle this setting if it’s enabled.

Regarding the associated variable CVarAllowMotionBlurInVR:

#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;
}