r.LocalFogVolume.TileDebug

r.LocalFogVolume.TileDebug

#Overview

name: r.LocalFogVolume.TileDebug

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LocalFogVolume.TileDebug is to provide debug visualization for the tiled rendering data complexity of local fog volumes in Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically for local fog volume rendering. It is part of the Renderer module in Unreal Engine 5.

The value of this variable is set through a console variable (CVar) named CVarLocalFogVolumeTileDebug. It is initialized with a default value of 0 and can be changed at runtime through console commands.

The variable interacts with the local fog volume rendering process. It is used to control the debug visualization mode for tiled rendering of local fog volumes.

Developers should be aware that this variable has three possible values: 0: No debug visualization (default) 1: Show per-tile local fog volume count as color 2: Same as 1, but also show the effect of pixel discard/clipping

Best practices when using this variable include:

  1. Use it only for debugging purposes, as it may impact performance when enabled.
  2. Be cautious when enabling it in production builds, as it could affect visual quality.
  3. Remember to disable it after debugging to ensure optimal performance.

The associated variable CVarLocalFogVolumeTileDebug is the actual console variable that controls the r.LocalFogVolume.TileDebug setting. It is defined as a TAutoConsoleVariable, which means it’s an integer variable that can be changed at runtime through console commands.

This variable is used in several places within the LocalFogVolumeRendering.cpp file:

  1. In the RenderLocalFogVolume function, where it’s used to set the LocalFogVolumeTileDebug parameter for the pixel shader.
  2. In the RenderLocalFogVolumeMobile function, where it’s used similarly for mobile rendering.
  3. In the RenderLocalFogVolumeHalfResMobile function, where it’s used for half-resolution rendering on mobile platforms.

In all these cases, the value is clamped between 0 and 2 to ensure it stays within the valid range of debug modes. Developers should use this variable through the r.LocalFogVolume.TileDebug console command rather than directly accessing CVarLocalFogVolumeTileDebug in code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:58

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLocalFogVolumeTileDebug(
	TEXT("r.LocalFogVolume.TileDebug"), 0,
	TEXT("Debug the tiled rendering data complexity. 1: show per tile LFV count as color ; 2: same as one but also show the effect of pixel discard/clipping."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLocalFogVolumeGlobalStartDistance(
	TEXT("r.LocalFogVolume.GlobalStartDistance"), 2000.0f,
	TEXT("The start distance in centimeter from which local fog volumes starts to appear."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:57

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarLocalFogVolumeTileDebug(
	TEXT("r.LocalFogVolume.TileDebug"), 0,
	TEXT("Debug the tiled rendering data complexity. 1: show per tile LFV count as color ; 2: same as one but also show the effect of pixel discard/clipping."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLocalFogVolumeGlobalStartDistance(
	TEXT("r.LocalFogVolume.GlobalStartDistance"), 2000.0f,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:799

Scope (from outer to inner):

file
function     void RenderLocalFogVolume

Source code excerpt:

			PassParameters->PS.View = GetShaderBinding(View.ViewUniformBuffer);
			PassParameters->PS.LFV = View.LocalFogVolumeViewData.UniformParametersStruct;
			PassParameters->PS.LocalFogVolumeTileDebug = FMath::Clamp(CVarLocalFogVolumeTileDebug.GetValueOnRenderThread(), 0, 2);

			PassParameters->SceneTextures = SceneTextures.UniformBuffer;
			PassParameters->TileDrawIndirectBuffer = View.LocalFogVolumeViewData.GPUTileDrawIndirectBuffer;
			PassParameters->RenderTargets[0] = FRenderTargetBinding(SceneColorTexture, ERenderTargetLoadAction::ENoAction);
			PassParameters->RenderTargets.DepthStencil = FDepthStencilBinding(SceneTextures.Depth.Target, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, FExclusiveDepthStencil::DepthRead_StencilWrite);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:1015

Scope (from outer to inner):

file
function     void RenderLocalFogVolumeMobile

Source code excerpt:

	PSParameters.View = View.GetShaderParameters();
	PSParameters.LFV = View.LocalFogVolumeViewData.UniformParametersStruct;
	PSParameters.LocalFogVolumeTileDebug = FMath::Clamp(CVarLocalFogVolumeTileDebug.GetValueOnRenderThread(), 0, 2);
	// PSParameters.MobileBasePass filled up by the RDG pass parameters.
	SetShaderParameters(RHICmdList, PixelShader, PixelShader.GetPixelShader(), PSParameters);

	RHICmdList.SetStreamSource(0, nullptr, 0);
	RHICmdList.DrawPrimitiveIndirect(View.LocalFogVolumeViewData.GPUTileDrawIndirectBuffer->GetIndirectRHICallBuffer(), 0);
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:1035

Scope (from outer to inner):

file
function     void RenderLocalFogVolumeHalfResMobile

Source code excerpt:

	PassParameters->View = View.GetShaderParameters();;
	PassParameters->LFV = View.LocalFogVolumeViewData.UniformParametersStruct;
	PassParameters->LocalFogVolumeTileDebug = FMath::Clamp(CVarLocalFogVolumeTileDebug.GetValueOnRenderThread(), 0, 2);
	PassParameters->MobileBasePass = CreateMobileBasePassUniformBuffer(GraphBuilder, View, EMobileBasePass::Opaque, EMobileSceneTextureSetupMode::SceneDepth);
	PassParameters->RenderTargets[0] = FRenderTargetBinding(View.LocalFogVolumeViewData.HalfResLocalFogVolumeView, ERenderTargetLoadAction::ENoAction);
	PassParameters->RenderTargets[1] = FRenderTargetBinding(View.LocalFogVolumeViewData.HalfResLocalFogVolumeDepth, ERenderTargetLoadAction::ENoAction);

	FMobileLocalFogVolumeTiledRenderHalfResPS::FPermutationDomain PsPermutationVector;
	auto PixelShader = View.ShaderMap->GetShader< FMobileLocalFogVolumeTiledRenderHalfResPS >(PsPermutationVector);