r.Mobile.PixelFogDepthTest

r.Mobile.PixelFogDepthTest

#Overview

name: r.Mobile.PixelFogDepthTest

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.Mobile.PixelFogDepthTest is to control whether depth and stencil tests are used for fog rendering in mobile graphics. This setting is specifically related to the mobile rendering system in Unreal Engine 5.

This setting variable is primarily used in the Renderer module, specifically in the mobile fog rendering subsystem. It’s referenced in the MobileFogRendering.cpp file, which is part of the mobile rendering pipeline.

The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s initialized with a default value of 1, meaning depth and stencil tests are enabled by default for fog rendering.

The associated variable CVarPixelFogDepthTest directly interacts with r.Mobile.PixelFogDepthTest. It’s used to retrieve the current value of the setting in the render thread.

Developers must be aware that this variable affects the performance and visual quality of fog rendering on mobile devices. Enabling depth and stencil tests (value 1) may provide more accurate fog rendering but could impact performance, especially on lower-end mobile devices.

Best practices when using this variable include:

  1. Testing the impact on performance and visual quality with both enabled (1) and disabled (0) settings.
  2. Considering device capabilities when deciding whether to enable or disable this feature.
  3. Using it in conjunction with other mobile rendering optimizations to achieve the best balance between visual quality and performance.

Regarding the associated variable CVarPixelFogDepthTest:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:31

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarPixelFogDepthTest(
	TEXT("r.Mobile.PixelFogDepthTest"),
	1,
	TEXT("Whether to use depth and stencil tests for fog rendering"),
	ECVF_RenderThreadSafe);

class FMobileFogVS : public FGlobalShader
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:30

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarPixelFogDepthTest(
	TEXT("r.Mobile.PixelFogDepthTest"),
	1,
	TEXT("Whether to use depth and stencil tests for fog rendering"),
	ECVF_RenderThreadSafe);

class FMobileFogVS : public FGlobalShader

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:157

Scope (from outer to inner):

file
function     void FMobileSceneRenderer::RenderFog

Source code excerpt:

	}

	const bool bUseDepthTest = CVarPixelFogDepthTest.GetValueOnRenderThread() != 0;
		
	SCOPED_DRAW_EVENT(RHICmdList, Fog);
		
	RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
	
	FGraphicsPipelineStateInitializer GraphicsPSOInit;