r.RayTracing.Shadows.Lights.Rect
r.RayTracing.Shadows.Lights.Rect
#Overview
name: r.RayTracing.Shadows.Lights.Rect
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables ray tracing shadows for rect light (default = 1)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Shadows.Lights.Rect is to enable or disable ray tracing shadows for rectangular lights in Unreal Engine’s rendering system. This setting variable is part of the ray tracing shadow system, specifically for rectangular light sources.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the LightRendering.cpp file within the Runtime/Renderer/Private directory.
The value of this variable is set through a console variable (CVarRayTracingShadowsRectLight) with a default value of 1, meaning ray tracing shadows for rectangular lights are enabled by default. The value can be changed at runtime using console commands or through project settings.
This variable interacts directly with its associated variable CVarRayTracingShadowsRectLight. They share the same value and purpose.
Developers must be aware that this variable affects the rendering performance and visual quality of shadows cast by rectangular lights when ray tracing is enabled. Enabling this feature may impact performance, especially on less powerful hardware.
Best practices when using this variable include:
- Consider the performance impact of enabling ray-traced shadows for rectangular lights, especially in scenes with many light sources.
- Use it in conjunction with other ray tracing settings for a consistent visual appearance.
- Test the visual and performance differences with this setting enabled and disabled to make informed decisions about its use in your project.
Regarding the associated variable CVarRayTracingShadowsRectLight:
The purpose of CVarRayTracingShadowsRectLight is to provide a programmatic way to access and modify the r.RayTracing.Shadows.Lights.Rect setting within the engine’s C++ code.
This variable is used in the Renderer module, specifically in the LightRendering.cpp file. It’s utilized in the ShouldRenderRayTracingShadowsForLightType function to determine if ray-traced shadows should be rendered for rectangular lights.
The value of CVarRayTracingShadowsRectLight is set when the console variable is initialized, but it can be modified at runtime through the console or engine API calls.
Developers should be aware that this variable is of type TAutoConsoleVariable
Best practices for using CVarRayTracingShadowsRectLight include:
- Access its value using GetValueOnRenderThread() when in render thread code.
- Consider caching the value if it’s accessed frequently, as reading console variables can have a small performance cost.
- Use this variable in conjunction with other ray tracing and shadow-related settings for consistent behavior across different light types.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:128
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingShadowsRectLight(
TEXT("r.RayTracing.Shadows.Lights.Rect"),
1,
TEXT("Enables ray tracing shadows for rect light (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAppliedLightFunctionOnHair(
TEXT("r.HairStrands.LightFunction"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingShadowsRectLight
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:127
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingShadowsRectLight(
TEXT("r.RayTracing.Shadows.Lights.Rect"),
1,
TEXT("Enables ray tracing shadows for rect light (default = 1)"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAppliedLightFunctionOnHair(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:204
Scope (from outer to inner):
file
function static bool ShouldRenderRayTracingShadowsForLightType
Source code excerpt:
return !!CVarRayTracingShadowsSpotLight.GetValueOnRenderThread();
case LightType_Rect:
return !!CVarRayTracingShadowsRectLight.GetValueOnRenderThread();
default:
return true;
}
}
bool ShouldRenderRayTracingShadows()