r.Ortho.VSM.ProjectViewOrigin

r.Ortho.VSM.ProjectViewOrigin

#Overview

name: r.Ortho.VSM.ProjectViewOrigin

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.Ortho.VSM.ProjectViewOrigin is to control the behavior of Virtual Shadow Map (VSM) clipmaps in orthographic camera views. Specifically, it enables or disables the movement of the World Origin of VSM clipmaps to focus around the ViewTarget (if present) in orthographic camera scenarios.

This setting variable is primarily used in the rendering system, particularly in the Virtual Shadow Maps subsystem of Unreal Engine 5. It is part of the Renderer module, as evidenced by its location in the VirtualShadowMapClipmap.cpp file within the Renderer’s private directory.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of true, meaning the feature is enabled by default. Developers can change this value at runtime using console commands or through project settings.

The associated variable CVarOrthoVSMProjectViewOrigin interacts directly with r.Ortho.VSM.ProjectViewOrigin. They share the same value and purpose, with CVarOrthoVSMProjectViewOrigin being the actual C++ variable used in the code to access the setting.

Developers should be aware that this variable only affects orthographic camera views and has no impact on perspective cameras. It’s specifically designed to improve VSM scaling and distribution in orthographic scenarios.

When using this variable, best practices include:

  1. Consider the performance implications of enabling this feature, as it may require additional calculations.
  2. Ensure that a ViewTarget is set when using orthographic cameras, as the feature relies on the ViewTarget for optimal functionality.
  3. Test the visual quality and performance with this setting both enabled and disabled to determine the best configuration for your specific use case.

Regarding the associated variable CVarOrthoVSMProjectViewOrigin:

The purpose of CVarOrthoVSMProjectViewOrigin is to provide programmatic access to the r.Ortho.VSM.ProjectViewOrigin setting within the C++ code.

This variable is used directly in the Renderer module, specifically in the Virtual Shadow Maps system. It’s accessed in the FVirtualShadowMapClipmap constructor to determine whether to adjust the World Origin for VSM clipmaps.

The value of CVarOrthoVSMProjectViewOrigin is set through the CVar system and is linked to the r.Ortho.VSM.ProjectViewOrigin console variable.

This variable interacts closely with other components of the VSM system, particularly those dealing with clipmap generation and orthographic camera handling.

Developers should be aware that changes to CVarOrthoVSMProjectViewOrigin will directly affect the behavior of VSM clipmaps in orthographic views. It’s important to consider the implications on shadow quality and performance when modifying this variable.

Best practices for using CVarOrthoVSMProjectViewOrigin include:

  1. Access its value using GetValueOnRenderThread() to ensure thread-safe operations.
  2. Consider caching the value if it’s accessed frequently, as CVar lookups can have a small performance cost.
  3. Be cautious when changing this value at runtime, as it may cause visual discontinuities in shadow rendering.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:108

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarOrthoVSMProjectViewOrigin(
	TEXT("r.Ortho.VSM.ProjectViewOrigin"),
	true,
	TEXT("Enable/Disable moving the WorldOrigin of the VSM clipmaps to focus around the ViewTarget (if present)"),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<bool> CVarOrthoVSMRayCastViewOrigin(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:107

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarOrthoVSMProjectViewOrigin(
	TEXT("r.Ortho.VSM.ProjectViewOrigin"),
	true,
	TEXT("Enable/Disable moving the WorldOrigin of the VSM clipmaps to focus around the ViewTarget (if present)"),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:187

Scope (from outer to inner):

file
function     FVirtualShadowMapClipmap::FVirtualShadowMapClipmap

Source code excerpt:

	WorldOrigin = CameraViewMatrices.GetViewOrigin();
	CameraToViewTarget = FVector::ZeroVector;
	if (bIsOrthographicCamera && CVarOrthoVSMProjectViewOrigin.GetValueOnRenderThread())
	{
		/**
		* If enabled, use the ViewTarget location as the WorldOrigin location, this helps with scaling VSMs in Ortho
		* as the clipmaps emanate more evenly from the focus of the view.
		* A ViewTarget is not always necessarily present, but there isn't really an alternative way to estimate the best
		* WorldOrigin for this effect to work well right now without the ViewTarget set.