r.RayTracing.Shadows.EnableTwoSidedGeometry
r.RayTracing.Shadows.EnableTwoSidedGeometry
#Overview
name: r.RayTracing.Shadows.EnableTwoSidedGeometry
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables two-sided geometry when tracing shadow rays (default = 1)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Shadows.EnableTwoSidedGeometry is to control the behavior of ray-traced shadows in Unreal Engine 5’s rendering system, specifically enabling or disabling two-sided geometry when tracing shadow rays.
This setting variable is primarily used in the ray tracing subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is part of the ray-traced shadows implementation.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning two-sided geometry for shadow rays is enabled by default.
The associated variable CVarRayTracingShadowsEnableTwoSidedGeometry directly interacts with r.RayTracing.Shadows.EnableTwoSidedGeometry. They share the same value and purpose.
Developers must be aware that this variable affects the accuracy and performance of ray-traced shadows. Enabling two-sided geometry (value = 1) may provide more accurate shadows for thin objects or objects with complex geometry, but it might also have a performance impact.
Best practices when using this variable include:
- Keep it enabled (1) for most scenarios to ensure accurate shadows.
- Consider disabling it (0) if performance is a critical issue and the visual difference is negligible for your specific use case.
- Test your scenes with both settings to find the right balance between visual quality and performance.
Regarding the associated variable CVarRayTracingShadowsEnableTwoSidedGeometry:
This is the actual console variable that controls the r.RayTracing.Shadows.EnableTwoSidedGeometry setting. It’s defined as a TAutoConsoleVariable
The purpose of CVarRayTracingShadowsEnableTwoSidedGeometry is the same as r.RayTracing.Shadows.EnableTwoSidedGeometry - to enable or disable two-sided geometry for ray-traced shadows.
This variable is used in the rendering module, specifically in the ray tracing shadows implementation. It’s accessed through the GetValueOnRenderThread() method, which ensures thread-safe access to the variable’s value.
The value of this variable is set when the engine initializes the console variables, but it can be changed at runtime through console commands.
Developers should be aware that changes to this variable will take effect on the render thread, which means there might be a slight delay before the changes are visible.
Best practices for using CVarRayTracingShadowsEnableTwoSidedGeometry include:
- Use it for debugging or fine-tuning performance in development builds.
- Be cautious about changing it frequently during gameplay, as it may cause hitches or visual inconsistencies.
- Consider exposing it as a user-configurable setting if shadow quality vs. performance is a key concern for your target audience.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:45
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingShadowsEnableTwoSidedGeometry(
TEXT("r.RayTracing.Shadows.EnableTwoSidedGeometry"),
1,
TEXT("Enables two-sided geometry when tracing shadow rays (default = 1)"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarRayTracingTransmissionSamplingDistanceCulling(
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingShadowsEnableTwoSidedGeometry
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:44
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsEnableTwoSidedGeometry(
TEXT("r.RayTracing.Shadows.EnableTwoSidedGeometry"),
1,
TEXT("Enables two-sided geometry when tracing shadow rays (default = 1)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingShadows.cpp:132
Scope (from outer to inner):
file
function bool EnableRayTracingShadowTwoSidedGeometry
Source code excerpt:
bool EnableRayTracingShadowTwoSidedGeometry()
{
return CVarRayTracingShadowsEnableTwoSidedGeometry.GetValueOnRenderThread() != 0;
}
uint32 GetRayTracingTransmissionMeanFreePathType()
{
uint32 MeanFreePathType = FMath::Clamp(CVarRayTracingTransmissionMeanFreePathType.GetValueOnRenderThread(), 0, 1);