r.SkyAtmosphere.DistantSkyLightLUT
r.SkyAtmosphere.DistantSkyLightLUT
#Overview
name: r.SkyAtmosphere.DistantSkyLightLUT
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable the generation the sky ambient lighting value.\n
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SkyAtmosphere.DistantSkyLightLUT is to enable the generation of sky ambient lighting values in Unreal Engine’s sky atmosphere rendering system. This setting variable is primarily used in the rendering subsystem, specifically for the sky atmosphere component.
Based on the callsites, this variable is utilized in the Renderer module of Unreal Engine, particularly in the SkyAtmosphereRendering.cpp file. It’s part of the sky atmosphere rendering system, which is responsible for creating realistic atmospheric effects in the game environment.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning it’s enabled by default. Developers can modify this value at runtime using console commands or through project settings.
This variable interacts closely with CVarSkyAtmosphereDistantSkyLightLUTAltitude, which determines the altitude at which sky samples are taken to integrate the sky lighting. Together, these variables control the generation and characteristics of the distant sky light lookup table (LUT).
Developers should be aware that:
- This variable affects performance and visual quality. Enabling it (value > 0) results in more realistic lighting but may have a performance cost.
- It’s marked as render thread safe and scalable, meaning it can be adjusted dynamically without causing thread safety issues.
Best practices when using this variable include:
- Consider performance implications when enabling or disabling this feature, especially on lower-end hardware.
- Use in conjunction with CVarSkyAtmosphereDistantSkyLightLUTAltitude for fine-tuning the sky lighting effect.
- Test different values in various lighting conditions to find the optimal balance between visual quality and performance.
Regarding the associated variable CVarSkyAtmosphereDistantSkyLightLUT:
The purpose of CVarSkyAtmosphereDistantSkyLightLUT is identical to r.SkyAtmosphere.DistantSkyLightLUT. It’s the actual console variable implementation that controls the feature.
This variable is used throughout the sky atmosphere rendering code to determine whether to generate and use the distant sky light LUT. It’s checked in various functions, such as FSkyAtmosphereRenderSceneInfo::GetDistantSkyLightLutTexture() and within the RenderSkyAtmosphereLookUpTables function.
The value is set through the console variable system and can be modified at runtime.
Developers should be aware that:
- This variable directly controls whether the distant sky light LUT is generated and used.
- When disabled (value <= 0), the system falls back to a black dummy texture instead of the generated LUT.
Best practices include:
- Use this variable for debugging or performance optimization.
- Consider exposing this option to end-users for performance scaling if the sky atmosphere is a significant part of your game’s visuals.
- Always test the visual impact of enabling/disabling this feature in various lighting scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:196
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSkyAtmosphereDistantSkyLightLUT(
TEXT("r.SkyAtmosphere.DistantSkyLightLUT"), 1,
TEXT("Enable the generation the sky ambient lighting value.\n"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarSkyAtmosphereDistantSkyLightLUTAltitude(
TEXT("r.SkyAtmosphere.DistantSkyLightLUT.Altitude"), 6.0f,
TEXT("The altitude at which the sky samples are taken to integrate the sky lighting. Default to 6km, typicaly cirrus clouds altitude.\n"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarSkyAtmosphereDistantSkyLightLUT
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:195
Scope: file
Source code excerpt:
////////////////////////////////////////////////////////////////////////// Distant Sky Light LUT
static TAutoConsoleVariable<int32> CVarSkyAtmosphereDistantSkyLightLUT(
TEXT("r.SkyAtmosphere.DistantSkyLightLUT"), 1,
TEXT("Enable the generation the sky ambient lighting value.\n"),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarSkyAtmosphereDistantSkyLightLUTAltitude(
TEXT("r.SkyAtmosphere.DistantSkyLightLUT.Altitude"), 6.0f,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:498
Scope (from outer to inner):
file
function TRefCountPtr<IPooledRenderTarget>& FSkyAtmosphereRenderSceneInfo::GetDistantSkyLightLutTexture
Source code excerpt:
TRefCountPtr<IPooledRenderTarget>& FSkyAtmosphereRenderSceneInfo::GetDistantSkyLightLutTexture()
{
if (CVarSkyAtmosphereDistantSkyLightLUT.GetValueOnRenderThread() > 0)
{
return DistantSkyLightLutTexture;
}
return GSystemTextures.BlackDummy;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1163
Scope (from outer to inner):
file
function void InitSkyAtmosphereForScene
Source code excerpt:
GRenderTargetPool.FindFreeElement(RHICmdList, Desc, MultiScatteredLuminanceLutTexture, TEXT("SkyAtmosphere.MultiScatteredLuminanceLut"));
if (CVarSkyAtmosphereDistantSkyLightLUT.GetValueOnRenderThread() > 0)
{
TRefCountPtr<IPooledRenderTarget>& DistantSkyLightLutTexture = SkyInfo.GetDistantSkyLightLutTexture();
Desc = FPooledRenderTargetDesc::Create2DDesc(
FIntPoint(1, 1),
TextureLUTFormat, FClearValueBinding::None, TexCreate_None, TexCreate_ShaderResource | TexCreate_UAV, false);
GRenderTargetPool.FindFreeElement(RHICmdList, Desc, DistantSkyLightLutTexture, TEXT("SkyAtmosphere.DistantSkyLightLut"));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1367
Scope (from outer to inner):
file
function void FSceneRenderer::RenderSkyAtmosphereLookUpTables
Source code excerpt:
// Distant Sky Light LUT
if(CVarSkyAtmosphereDistantSkyLightLUT.GetValueOnRenderThread() > 0)
{
FRDGTextureRef DistantSkyLightLut = GraphBuilder.RegisterExternalTexture(SkyInfo.GetDistantSkyLightLutTexture());
FRDGTextureUAVRef DistantSkyLightLutUAV = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(DistantSkyLightLut, 0));
FRenderDistantSkyLightLutCS::FPermutationDomain PermutationVector;
PermutationVector.Set<FSecondAtmosphereLight>(bSecondAtmosphereLightEnabled);