r.Shadow.TexelsPerPixelPointlight
r.Shadow.TexelsPerPixelPointlight
#Overview
name: r.Shadow.TexelsPerPixelPointlight
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The ratio of subject pixels to shadow texels for point lights
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Shadow.TexelsPerPixelPointlight is to control the ratio of subject pixels to shadow texels for point lights in the rendering system of Unreal Engine 5. This setting variable is crucial for managing the quality and performance of shadow rendering for point lights.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically in the shadow setup and creation process. It’s referenced in the ShadowSetup.cpp file, which is part of the rendering subsystem.
The value of this variable is set as a console variable (CVar) with a default value of 1.27324f. It can be modified at runtime through the console or configuration files.
The variable interacts closely with similar variables for other light types, such as CVarShadowTexelsPerPixelSpotlight and CVarShadowTexelsPerPixelRectlight. These variables work together to determine the resolution of shadows for different light types.
Developers must be aware that this variable directly affects the quality and performance of point light shadows. A higher value will result in higher quality shadows but may impact performance, especially in scenes with many point lights.
Best practices when using this variable include:
- Balancing quality and performance based on the target hardware and scene complexity.
- Testing different values to find the optimal setting for specific use cases.
- Considering adjusting this value dynamically based on the scene or distance from the camera.
Regarding the associated variable CVarShadowTexelsPerPixelPointlight:
This is the actual console variable that stores and manages the r.Shadow.TexelsPerPixelPointlight setting. It’s defined using the TAutoConsoleVariable template, which allows for runtime modification and thread-safe access.
The variable is used in the CreateWholeSceneProjectedShadow function to calculate the UnclampedResolution for point light shadows. This calculation directly influences the shadow map resolution for point lights.
Developers should note that this variable is accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in the rendering pipeline. When modifying this value, it’s important to consider its impact on both visual quality and rendering performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:211
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarShadowTexelsPerPixelPointlight(
TEXT("r.Shadow.TexelsPerPixelPointlight"),
1.27324f,
TEXT("The ratio of subject pixels to shadow texels for point lights"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarShadowTexelsPerPixelSpotlight(
TEXT("r.Shadow.TexelsPerPixelSpotlight"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarShadowTexelsPerPixelPointlight
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:210
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarShadowTexelsPerPixelPointlight(
TEXT("r.Shadow.TexelsPerPixelPointlight"),
1.27324f,
TEXT("The ratio of subject pixels to shadow texels for point lights"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarShadowTexelsPerPixelSpotlight(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:4088
Scope (from outer to inner):
file
function void FSceneRenderer::CreateWholeSceneProjectedShadow
Source code excerpt:
{
case LightType_Point:
UnclampedResolution = ScreenRadius * CVarShadowTexelsPerPixelPointlight.GetValueOnRenderThread();
break;
case LightType_Spot:
UnclampedResolution = ScreenRadius * CVarShadowTexelsPerPixelSpotlight.GetValueOnRenderThread();
break;
case LightType_Rect:
UnclampedResolution = ScreenRadius * CVarShadowTexelsPerPixelRectlight.GetValueOnRenderThread();