r.ViewRectUseScreenBottom

r.ViewRectUseScreenBottom

#Overview

name: r.ViewRectUseScreenBottom

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ViewRectUseScreenBottom is to modify the positioning of the view rectangle in the rendering system. It is an experimental feature that changes the origin point of the view rectangle from the default top-left corner to the bottom-left corner of the screen.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the scene rendering subsystem. It affects how the view rectangle is calculated and positioned during the rendering process.

The value of this variable is set through a console variable (CVar) system in Unreal Engine. It is defined as a TAutoConsoleVariable with an initial value of 0 (disabled by default).

The associated variable CVarViewRectUseScreenBottom directly interacts with r.ViewRectUseScreenBottom. They share the same value and purpose, with CVarViewRectUseScreenBottom being the actual variable used in the C++ code to check the setting’s value.

Developers must be aware of several important points when using this variable:

  1. It is an experimental and unsupported feature.
  2. It does not work correctly with all post-processing effects, specifically mentioning issues with Depth of Field (DOF) and Distance Field Ambient Occlusion (DFAO).
  3. Enabling this feature will affect the positioning of the entire rendered view, which may have unintended consequences on various rendering systems and game logic that rely on screen space calculations.

Best practices when using this variable include:

  1. Only use it for specific experimental purposes or debugging.
  2. Thoroughly test all rendering features, especially post-processing effects, when enabling this variable.
  3. Be cautious about using this in production builds due to its experimental nature.
  4. Consider the impact on performance and compatibility with other rendering features before enabling it.

Regarding the associated variable CVarViewRectUseScreenBottom:

The purpose of CVarViewRectUseScreenBottom is to provide a programmatic way to access and modify the r.ViewRectUseScreenBottom setting within the C++ code of the Unreal Engine renderer.

This variable is used directly in the rendering code to determine whether to adjust the view rectangle positioning. It’s accessed using the GetValueOnRenderThread() method, which ensures thread-safe access to the variable’s value during rendering.

The value of CVarViewRectUseScreenBottom is set through the console variable system, mirroring the value of r.ViewRectUseScreenBottom.

Developers should be aware that modifying CVarViewRectUseScreenBottom directly in code will have the same effect as changing r.ViewRectUseScreenBottom through the console or configuration files. They should also note that this variable is marked as render thread safe, meaning it can be safely accessed and modified on the render thread without causing threading issues.

Best practices for using CVarViewRectUseScreenBottom include:

  1. Access its value using GetValueOnRenderThread() when in rendering code to ensure thread safety.
  2. Consider caching the value if it’s accessed frequently to avoid potential performance overhead from repeated console variable lookups.
  3. Be cautious about changing its value at runtime, as it can have significant impacts on the rendering output.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:230

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarViewRectUseScreenBottom(
	TEXT("r.ViewRectUseScreenBottom"),
	0,
	TEXT("WARNING: This is an experimental, unsupported feature and does not work with all postprocesses (e.g DOF and DFAO)\n")
	TEXT("If enabled, the view rectangle will use the bottom left corner instead of top left"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

This variable is associated with another variable named CVarViewRectUseScreenBottom. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:229

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarViewRectUseScreenBottom(
	TEXT("r.ViewRectUseScreenBottom"),
	0,
	TEXT("WARNING: This is an experimental, unsupported feature and does not work with all postprocesses (e.g DOF and DFAO)\n")
	TEXT("If enabled, the view rectangle will use the bottom left corner instead of top left"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3128

Scope (from outer to inner):

file
function     void FSceneRenderer::PrepareViewRectsForRendering

Source code excerpt:


		// Use the bottom-left view rect if requested, instead of top-left
		if (CVarViewRectUseScreenBottom.GetValueOnRenderThread())
		{
			ViewRectMin.Y = FMath::CeilToInt( View.UnscaledViewRect.Max.Y * ViewFamily.SecondaryViewFraction ) - ViewSize.Y;
		}

		View.ViewRect.Min = ViewRectMin;
		View.ViewRect.Max = ViewRectMin + ViewSize;