r.SkyLight.RealTimeReflectionCapture.DepthBuffer

r.SkyLight.RealTimeReflectionCapture.DepthBuffer

#Overview

name: r.SkyLight.RealTimeReflectionCapture.DepthBuffer

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SkyLight.RealTimeReflectionCapture.DepthBuffer is to control whether a depth buffer is used in real-time sky light reflection captures. This setting is primarily used in the rendering system, specifically for sky light and reflection capture functionality.

This setting variable is relied upon by the Unreal Engine’s Renderer module, particularly in the real-time reflection capture system. It’s used in the file ReflectionEnvironmentRealTimeCapture.cpp, which suggests it’s closely tied to the reflection environment and real-time capture features.

The value of this variable is set through a console variable (CVarRealTimeReflectionCaptureDepthBuffer) with a default value of 1 (enabled). It can be changed at runtime through console commands or programmatically.

The associated variable CVarRealTimeReflectionCaptureDepthBuffer directly interacts with it. They share the same value and purpose.

Developers must be aware that enabling this variable (set to 1) will cause the real-time sky light capture to use a depth buffer. This is important for correctly handling multiple meshes that may overlap each other in the reflection capture. Additionally, it affects how height fog is applied, using the depth buffer for more accurate results.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) for most scenarios to ensure correct rendering of overlapping meshes and accurate height fog in reflections.
  2. Consider disabling it (set to 0) only if you’re experiencing performance issues and have determined that the depth buffer in reflection captures is a significant contributor to those issues.
  3. When modifying this value, test thoroughly in various lighting conditions and with complex scenes to ensure desired visual results.
  4. Be aware that changing this value may affect the visual fidelity of reflections, particularly in scenes with multiple overlapping objects or significant use of height fog.

Regarding the associated variable CVarRealTimeReflectionCaptureDepthBuffer:

This is a console variable that directly controls the r.SkyLight.RealTimeReflectionCapture.DepthBuffer setting. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime. The variable is used in the render thread to determine whether to use a depth buffer for real-time reflection captures.

Developers should be aware that this variable is marked as render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed and modified from the render thread. When accessing this variable’s value, use the GetValueOnRenderThread() method to ensure thread-safe access, as demonstrated in the provided code snippet.

Best practices for using CVarRealTimeReflectionCaptureDepthBuffer include:

  1. Use GetValueOnRenderThread() when accessing its value in render thread code.
  2. If you need to modify this variable programmatically, ensure you’re doing so in a thread-safe manner.
  3. Consider exposing this setting in your game’s graphics options menu to allow users to toggle it if performance is a concern.
  4. When debugging reflection or sky light issues, check the value of this variable to ensure it’s set as expected for your use case.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironmentRealTimeCapture.cpp:46

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRealTimeReflectionCaptureDepthBuffer(
	TEXT("r.SkyLight.RealTimeReflectionCapture.DepthBuffer"), 1,
	TEXT("When enabled, the real-time sky light capture will have a depth buffer, this is for multiple meshes to be cover each other correctly. The height fog will also be applied according to the depth buffer."),
	ECVF_RenderThreadSafe);


class FDownsampleCubeFaceCS : public FGlobalShader
{

#Associated Variable and Callsites

This variable is associated with another variable named CVarRealTimeReflectionCaptureDepthBuffer. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironmentRealTimeCapture.cpp:45

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRealTimeReflectionCaptureDepthBuffer(
	TEXT("r.SkyLight.RealTimeReflectionCapture.DepthBuffer"), 1,
	TEXT("When enabled, the real-time sky light capture will have a depth buffer, this is for multiple meshes to be cover each other correctly. The height fog will also be applied according to the depth buffer."),
	ECVF_RenderThreadSafe);


class FDownsampleCubeFaceCS : public FGlobalShader

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ReflectionEnvironmentRealTimeCapture.cpp:591

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

				SkyRC.VolumetricCloudSkyAO = CloudShadowAOData.VolumetricCloudSkyAO;

				const bool bUseDepthBuffer = CVarRealTimeReflectionCaptureDepthBuffer.GetValueOnRenderThread() > 0;
				FRDGTextureRef CubeDepthTexture = nullptr;

				if (bExecuteSky)
				{
					if(MainView.bSceneHasSkyMaterial || bShouldRenderSkyAtmosphere)
					{