r.SkyAtmosphere.AerialPerspective.DepthTest
r.SkyAtmosphere.AerialPerspective.DepthTest
#Overview
name: r.SkyAtmosphere.AerialPerspective.DepthTest
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled, a depth test will be used to not write pixel closer to the camera than StartDepth, effectively improving performance.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SkyAtmosphere.AerialPerspective.DepthTest is to control the depth testing behavior for aerial perspective rendering in the Sky Atmosphere system of Unreal Engine 5.
This setting variable is primarily used in the rendering system, specifically for the Sky Atmosphere rendering module. It is part of the atmospheric rendering subsystem within Unreal Engine.
Based on the callsites, this variable is utilized in the SkyAtmosphereRendering.cpp file, which is part of the Renderer module in Unreal Engine. The Sky Atmosphere rendering system relies on this setting to optimize performance during aerial perspective rendering.
The value of this variable is set using a console variable (CVarSkyAtmosphereAerialPerspectiveDepthTest) with a default value of 1 (enabled). It can be modified at runtime through the console or configuration files.
This variable interacts closely with other Sky Atmosphere rendering parameters, particularly those related to aerial perspective rendering. It is associated with the C++ variable CVarSkyAtmosphereAerialPerspectiveDepthTest, which is used to access and modify its value within the engine’s code.
Developers should be aware that enabling this variable (which is the default behavior) will use a depth test to avoid writing pixels closer to the camera than a certain start depth. This can significantly improve rendering performance for sky atmosphere effects.
Best practices when using this variable include:
- Keep it enabled by default for optimal performance.
- Consider disabling it only if you encounter specific visual artifacts related to aerial perspective near the camera.
- Test thoroughly when modifying this setting, as it can affect both performance and visual quality.
Regarding the associated variable CVarSkyAtmosphereAerialPerspectiveDepthTest:
The purpose of CVarSkyAtmosphereAerialPerspectiveDepthTest is to provide programmatic access to the r.SkyAtmosphere.AerialPerspective.DepthTest setting within the engine’s C++ code.
This variable is used directly in the rendering code, specifically in the FSceneRenderer::RenderSkyAtmosphere function, to determine whether to enable fast aerial perspective depth testing.
The value of this variable is set and modified through the console variable system, which allows for runtime configuration.
It interacts closely with other rendering parameters in the Sky Atmosphere system, influencing how aerial perspective is computed and applied.
Developers working with the Sky Atmosphere rendering code should be aware that this variable directly controls the depth testing behavior for aerial perspective. Changes to its value will immediately affect the rendering pipeline.
Best practices for using this variable in code include:
- Access its value using the GetValueOnRenderThread() method to ensure thread-safe operations.
- Consider the performance implications when deciding whether to enable or disable this feature programmatically.
- Use this variable in conjunction with other Sky Atmosphere rendering parameters for fine-tuned control over the atmospheric rendering process.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:109
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSkyAtmosphereAerialPerspectiveDepthTest(
TEXT("r.SkyAtmosphere.AerialPerspective.DepthTest"), 1,
TEXT("When enabled, a depth test will be used to not write pixel closer to the camera than StartDepth, effectively improving performance."),
ECVF_RenderThreadSafe | ECVF_Scalability);
////////////////////////////////////////////////////////////////////////// Aerial perspective LUT
static TAutoConsoleVariable<float> CVarSkyAtmosphereAerialPerspectiveLUTDepthResolution(
#Associated Variable and Callsites
This variable is associated with another variable named CVarSkyAtmosphereAerialPerspectiveDepthTest
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:108
Scope: file
Source code excerpt:
////////////////////////////////////////////////////////////////////////// Aerial perspective
static TAutoConsoleVariable<int32> CVarSkyAtmosphereAerialPerspectiveDepthTest(
TEXT("r.SkyAtmosphere.AerialPerspective.DepthTest"), 1,
TEXT("When enabled, a depth test will be used to not write pixel closer to the camera than StartDepth, effectively improving performance."),
ECVF_RenderThreadSafe | ECVF_Scalability);
////////////////////////////////////////////////////////////////////////// Aerial perspective LUT
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1960
Scope (from outer to inner):
file
function void FSceneRenderer::RenderSkyAtmosphere
Source code excerpt:
SkyRC.bFastSky = CVarSkyAtmosphereFastSkyLUT.GetValueOnRenderThread() > 0;
SkyRC.bFastAerialPerspective = CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque.GetValueOnRenderThread() > 0;
SkyRC.bFastAerialPerspectiveDepthTest = CVarSkyAtmosphereAerialPerspectiveDepthTest.GetValueOnRenderThread() > 0;
SkyRC.bSecondAtmosphereLightEnabled = Scene->IsSecondAtmosphereLightEnabled();
SkyAtmosphereLightShadowData LightShadowData;
SkyRC.bShouldSampleOpaqueShadow = ShouldSkySampleAtmosphereLightsOpaqueShadow(*Scene, VisibleLightInfos, LightShadowData);
SkyRC.bUseDepthBoundTestIfPossible = true;
SkyRC.bForceRayMarching = false;