r.Ortho.VSM.RayCastViewOrigin
r.Ortho.VSM.RayCastViewOrigin
#Overview
name: r.Ortho.VSM.RayCastViewOrigin
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable/Disable whether the ViewOrigin should be estimated with a raycast if the ViewTarget is not present (i.e. standalone camera)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Ortho.VSM.RayCastViewOrigin is to control whether the ViewOrigin should be estimated using a raycast when the ViewTarget is not present, specifically for orthographic virtual shadow maps (VSM).
This setting variable is primarily used in the rendering system, specifically within the Virtual Shadow Map subsystem of Unreal Engine 5. It is implemented in the VirtualShadowMapClipmap.cpp file, which is part of the Renderer module.
The value of this variable is set through a console variable (CVarOrthoVSMRayCastViewOrigin) using the TAutoConsoleVariable template. It is initialized with a default value of true, meaning the raycast estimation is enabled by default.
The associated variable CVarOrthoVSMRayCastViewOrigin directly interacts with r.Ortho.VSM.RayCastViewOrigin. They share the same value and purpose.
Developers must be aware that this variable affects the behavior of virtual shadow maps in orthographic views, particularly when dealing with standalone cameras or situations where the ViewTarget is not available. When enabled, it allows the engine to estimate the ViewOrigin using a raycast, which can be crucial for proper shadow rendering in certain scenarios.
Best practices when using this variable include:
- Understanding the implications of enabling or disabling this feature on shadow quality and performance.
- Testing the visual impact in scenes with orthographic cameras or where ViewTargets might be absent.
- Considering performance implications, as raycasting can have a computational cost.
- Using it in conjunction with other virtual shadow map settings for optimal results.
Regarding the associated variable CVarOrthoVSMRayCastViewOrigin:
This is the actual console variable that controls the r.Ortho.VSM.RayCastViewOrigin setting. It is defined using the TAutoConsoleVariable template, which allows it to be changed at runtime through console commands.
The purpose of CVarOrthoVSMRayCastViewOrigin is the same as r.Ortho.VSM.RayCastViewOrigin - to enable or disable the ViewOrigin estimation using raycast for orthographic virtual shadow maps.
This variable is used in the Renderer module, specifically in the Virtual Shadow Map system. Its value is checked in the FVirtualShadowMapClipmap constructor to determine whether to perform the raycast for ViewOrigin estimation.
The value of CVarOrthoVSMRayCastViewOrigin can be set through console commands or programmatically. It’s important to note that it has the ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating that it’s safe to change on the render thread and can be used for scalability settings.
Developers should be aware that changing this variable at runtime will immediately affect the behavior of orthographic virtual shadow maps. They should also consider the potential performance impact of enabling this feature, especially in scenes with complex geometry where raycasts might be costly.
Best practices for using CVarOrthoVSMRayCastViewOrigin include:
- Using it in conjunction with other virtual shadow map and rendering settings for optimal performance and visual quality.
- Profiling the performance impact of enabling this feature in your specific use cases.
- Considering exposing this setting to end-users for fine-tuning shadow quality on different hardware configurations.
#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:115
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarOrthoVSMRayCastViewOrigin(
TEXT("r.Ortho.VSM.RayCastViewOrigin"),
true,
TEXT("Enable/Disable whether the ViewOrigin should be estimated with a raycast if the ViewTarget is not present (i.e. standalone camera)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
// "Virtual" clipmap level to clipmap radius
#Associated Variable and Callsites
This variable is associated with another variable named CVarOrthoVSMRayCastViewOrigin
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:114
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<bool> CVarOrthoVSMRayCastViewOrigin(
TEXT("r.Ortho.VSM.RayCastViewOrigin"),
true,
TEXT("Enable/Disable whether the ViewOrigin should be estimated with a raycast if the ViewTarget is not present (i.e. standalone camera)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VirtualShadowMaps/VirtualShadowMapClipmap.cpp:196
Scope (from outer to inner):
file
function FVirtualShadowMapClipmap::FVirtualShadowMapClipmap
Source code excerpt:
*/
CameraToViewTarget = CameraViewMatrices.GetCameraToViewTarget();
if (CameraToViewTarget.Length() == 0.0f && CVarOrthoVSMRayCastViewOrigin.GetValueOnRenderThread()
&& DependentView && DependentView->Family && DependentView->Family->Scene)
{
if (UWorld* World = DependentView->Family->Scene->GetWorld())
{
FVector ViewForward = CameraViewMatrices.GetViewMatrix().GetColumn(2);
FCollisionObjectQueryParams ObjectParams = FCollisionObjectQueryParams(FCollisionObjectQueryParams::InitType::AllObjects);