bSupportsDistanceFields

bSupportsDistanceFields

#Overview

name: bSupportsDistanceFields

The value of this variable can be defined or overridden in .ini config files. 9 .ini config files referencing this setting variable.

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bSupportsDistanceFields is to indicate whether the current GPU hardware and driver combination supports distance field rendering techniques. Distance fields are used for various rendering effects, particularly in the areas of ambient occlusion and shadowing.

This setting variable is primarily used by the rendering system in Unreal Engine 5. Based on the callsites, it’s specifically utilized in the Metal RHI (Runtime Hardware Interface) for Apple platforms and in the general RHI system for cross-platform support.

The value of this variable is set in the Metal RHI initialization code for Apple platforms. For other platforms, it’s likely set in their respective RHI initialization code or through the data-driven shader platform info system.

This variable interacts with other rendering-related variables and settings, such as bSupportsTiledReflections and GSupportsTimestampRenderQueries. It’s also used in conjunction with command-line parameters and console variables related to distance field effects.

Developers must be aware that this variable’s value can affect the availability of certain rendering features, particularly distance field ambient occlusion (DFAO) and distance field shadows. If the variable is false, these features may be automatically disabled to prevent incorrect shader execution.

Best practices when using this variable include:

  1. Checking its value before enabling distance field-related rendering features.
  2. Providing fallback rendering techniques for platforms or hardware that don’t support distance fields.
  3. Using it in conjunction with other capability checks to ensure a consistent rendering experience across different hardware.
  4. Being aware that its value can be overridden by command-line parameters for testing purposes.
  5. Considering its impact on performance and adjusting rendering settings accordingly.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/DataDrivenPlatformInfo.ini:120, section: [ShaderPlatform VULKAN_SM5_ANDROID]

Location: <Workspace>/Engine/Config/IOS/DataDrivenPlatformInfo.ini:71, section: [ShaderPlatform METAL_MRT]

Location: <Workspace>/Engine/Config/Mac/DataDrivenPlatformInfo.ini:34, section: [ShaderPlatform METAL_SM5]

Location: <Workspace>/Engine/Config/Mac/DataDrivenPlatformInfo.ini:74, section: [ShaderPlatform METAL_SM6]

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:32, section: [ShaderPlatform VULKAN_SM5]

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:159, section: [ShaderPlatform VULKAN_SM6]

Location: <Workspace>/Engine/Config/Windows/DataDrivenPlatformInfo.ini:55, section: [ShaderPlatform PCD3D_SM5]

Location: <Workspace>/Engine/Config/Windows/DataDrivenPlatformInfo.ini:106, section: [ShaderPlatform PCD3D_SM6]

Location: <Workspace>/Engine/Config/Windows/DataDrivenPlatformInfo.ini:152, section: [ShaderPlatform PCD3D_ES3_1]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:331

Scope: file

Source code excerpt:

	// However they don't all support other features depending on the version of the OS.
	bool bSupportsTiledReflections = false;
	bool bSupportsDistanceFields = false;
	
    bool bSupportsSM6 = false;
	bool bSupportsSM5 = true;
	bool bIsIntelHaswell = false;
	
	GSupportsTimestampRenderQueries = true;

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:350

Scope: file

Source code excerpt:

		}
		bSupportsTiledReflections = true;
		bSupportsDistanceFields = true;
		
		// On AMD can also use completion handler time stamp if macOS < Catalina
		GSupportsTimestampRenderQueries = true;
		
		// Only tested on Vega.
		GRHISupportsWaveOperations = GRHIAdapterName.Contains(TEXT("Vega"));

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:368

Scope: file

Source code excerpt:

		bSupportsPointLights = true;
		GRHIVendorId = (uint32)EGpuVendorId::Intel;
		bSupportsDistanceFields = true;
		bIsIntelHaswell = (GRHIAdapterName == TEXT("Intel HD Graphics 5000") || GRHIAdapterName == TEXT("Intel Iris Graphics") || GRHIAdapterName == TEXT("Intel Iris Pro Graphics"));
		GRHISupportsWaveOperations = false;
	}
	else if(GRHIAdapterName.Contains("Apple"))
	{
		bSupportsPointLights = true;
		GRHIVendorId = (uint32)EGpuVendorId::Apple;
		bSupportsTiledReflections = true;
		bSupportsDistanceFields = true;
		GSupportsTimestampRenderQueries = true;
		
		GRHISupportsWaveOperations = true;
		GRHIMinimumWaveSize = 32;
		GRHIMaximumWaveSize = 32;

#Loc: <Workspace>/Engine/Source/Runtime/Apple/MetalRHI/Private/MetalRHI.cpp:500

Scope: file

Source code excerpt:

	
	// Disable the distance field AO & shadowing effects on GPU drivers that don't currently execute the shaders correctly.
	if ((GMaxRHIShaderPlatform == SP_METAL_SM5 || GMaxRHIShaderPlatform == SP_METAL_SM6) && !bSupportsDistanceFields && !FParse::Param(FCommandLine::Get(),TEXT("metaldistancefields")))
	{
		static auto CVarDistanceFieldAO = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DistanceFieldAO"));
		if(CVarDistanceFieldAO && CVarDistanceFieldAO->GetInt() != 0)
		{
			CVarDistanceFieldAO->Set(0);
		}

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/DataDrivenShaderPlatformInfo.cpp:206

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo

Source code excerpt:

	GET_SECTION_BOOL_HELPER(bSupportsMobileMultiView);
	GET_SECTION_BOOL_HELPER(bSupportsArrayTextureCompression);
	GET_SECTION_BOOL_HELPER(bSupportsDistanceFields);
	GET_SECTION_BOOL_HELPER(bSupportsDiaphragmDOF);
	GET_SECTION_BOOL_HELPER(bSupportsRGBColorBuffer);
	GET_SECTION_BOOL_HELPER(bSupportsCapsuleShadows);
	GET_SECTION_BOOL_HELPER(bSupportsPercentageCloserShadows);
	GET_SECTION_BOOL_HELPER(bSupportsIndexBufferUAVs);
	GET_SECTION_BOOL_HELPER(bSupportsInstancedStereo);

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:32

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo

Source code excerpt:

	uint32 bSupportsMobileMultiView : 1;
	uint32 bSupportsArrayTextureCompression : 1;
	uint32 bSupportsDistanceFields : 1; // used for DFShadows and DFAO - since they had the same checks
	uint32 bSupportsDiaphragmDOF : 1;
	uint32 bSupportsRGBColorBuffer : 1;
	uint32 bSupportsCapsuleShadows : 1;
	uint32 bSupportsPercentageCloserShadows : 1;
	uint32 bSupportsIndexBufferUAVs : 1;
	uint32 bSupportsInstancedStereo : 1;

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:251

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo
function     static const bool GetSupportsDistanceFields

Source code excerpt:

	{
		check(IsValid(Platform));
		return Infos[Platform].bSupportsDistanceFields;
	}

	static FORCEINLINE_DEBUGGABLE const bool GetSupportsDiaphragmDOF(const FStaticShaderPlatform Platform)
	{
		check(IsValid(Platform));
		return Infos[Platform].bSupportsDiaphragmDOF;