r.ManyLights.TexturedRectLights
r.ManyLights.TexturedRectLights
#Overview
name: r.ManyLights.TexturedRectLights
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to support textured rect lights.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ManyLights.TexturedRectLights is to control whether textured rect lights are supported in the Many Lights rendering system of Unreal Engine 5.
This setting variable is primarily used in the rendering system, specifically in the Many Lights module. It is referenced in the ManyLights.cpp file, which is part of the Renderer module in Unreal Engine.
The value of this variable is set through a console variable (CVarManyLightsTexturedRectLights) with an initial value of 0, meaning textured rect lights are disabled by default. It can be changed at runtime using console commands or through engine configuration.
The variable interacts with other rendering-related variables in the Many Lights system, such as CVarManyLightsIESProfiles and CVarManyLightsLightFunctions. It is used in shader permutations for light sample generation and shading.
Developers should be aware that enabling this feature may have performance implications, as it adds complexity to the lighting calculations. It should be used judiciously and tested thoroughly to ensure it doesn’t negatively impact performance, especially on lower-end hardware.
Best practices when using this variable include:
- Only enable it when textured rect lights are actually needed in the scene.
- Profile the performance impact before and after enabling this feature.
- Consider making it a scalability option, allowing it to be toggled based on hardware capabilities.
Regarding the associated variable CVarManyLightsTexturedRectLights:
This is the actual console variable that controls the r.ManyLights.TexturedRectLights setting. It is defined as a TAutoConsoleVariable
The purpose of CVarManyLightsTexturedRectLights is to provide a runtime-configurable way to enable or disable textured rect light support. It is used in the same contexts as r.ManyLights.TexturedRectLights, specifically in the light sample generation and shading passes of the Many Lights system.
The value of this variable is accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.
Developers should use this console variable when they need to programmatically check or modify the textured rect lights setting. It’s important to note that changes to this variable will affect rendering in real-time, so it should be used carefully, especially in performance-critical scenarios.
Best practices for using CVarManyLightsTexturedRectLights include:
- Always access its value using GetValueOnRenderThread() when in render thread code.
- Consider caching the value if it’s accessed frequently, to avoid repeated calls to GetValueOnRenderThread().
- Use it in conjunction with other Many Lights settings for a cohesive lighting strategy.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:122
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int> CVarManyLightsTexturedRectLights(
TEXT("r.ManyLights.TexturedRectLights"),
0,
TEXT("Whether to support textured rect lights."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int> CVarManyLightsLightFunctions(
#Associated Variable and Callsites
This variable is associated with another variable named CVarManyLightsTexturedRectLights
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:121
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int> CVarManyLightsTexturedRectLights(
TEXT("r.ManyLights.TexturedRectLights"),
0,
TEXT("Whether to support textured rect lights."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:929
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderManyLights
Source code excerpt:
PermutationVector.Set<FGenerateLightSamplesCS::FIESProfile>(CVarManyLightsIESProfiles.GetValueOnRenderThread() != 0);
PermutationVector.Set<FGenerateLightSamplesCS::FLightFunctionAtlas>(bUseLightFunctionAtlas);
PermutationVector.Set<FGenerateLightSamplesCS::FTexturedRectLights>(CVarManyLightsTexturedRectLights.GetValueOnRenderThread() != 0);
PermutationVector.Set<FGenerateLightSamplesCS::FNumSamplesPerPixel1d>(NumSamplesPerPixel2d.X * NumSamplesPerPixel2d.Y);
PermutationVector.Set<FGenerateLightSamplesCS::FDebugMode>(bDebug);
auto ComputeShader = View.ShaderMap->GetShader<FGenerateLightSamplesCS>(PermutationVector);
FComputeShaderUtils::AddPass(
GraphBuilder,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:1072
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderManyLights
Source code excerpt:
PermutationVector.Set<FShadeLightSamplesCS::FIESProfile>(CVarManyLightsIESProfiles.GetValueOnRenderThread() != 0);
PermutationVector.Set<FShadeLightSamplesCS::FLightFunctionAtlas>(bUseLightFunctionAtlas);
PermutationVector.Set<FShadeLightSamplesCS::FTexturedRectLights>(CVarManyLightsTexturedRectLights.GetValueOnRenderThread() != 0);
PermutationVector.Set<FShadeLightSamplesCS::FDebugMode>(bDebug);
auto ComputeShader = View.ShaderMap->GetShader<FShadeLightSamplesCS>(PermutationVector);
FComputeShaderUtils::AddPass(
GraphBuilder,
RDG_EVENT_NAME("ShadeLightSamples TileType:%d", TileType),