r.FastVRam.DistanceFieldAODownsampledBentNormal

r.FastVRam.DistanceFieldAODownsampledBentNormal

#Overview

name: r.FastVRam.DistanceFieldAODownsampledBentNormal

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.FastVRam.DistanceFieldAODownsampledBentNormal is to control the texture creation flags for the downsampled bent normal texture used in Distance Field Ambient Occlusion (DFAO) calculations. This setting is part of the rendering system, specifically the Distance Field lighting subsystem in Unreal Engine 5.

Based on the callsites, this setting variable is primarily used in the Renderer module of Unreal Engine 5. It’s utilized in the Distance Field Ambient Occlusion screen grid rendering process.

The value of this variable is set through the FASTVRAM_CVAR macro, which likely creates a console variable (CVar) for runtime configuration. It’s initialized with a value of 1, indicating that by default, the engine will use fast VRAM for this texture.

The associated variable DistanceFieldAODownsampledBentNormal interacts closely with r.FastVRam.DistanceFieldAODownsampledBentNormal. They share the same value, which is used to set the texture creation flags for the downsampled bent normal texture.

Developers should be aware that this variable affects the memory allocation strategy for the downsampled bent normal texture used in DFAO calculations. Setting this to 1 (default) will prioritize using fast VRAM for this texture, which can improve rendering performance but may increase VRAM usage.

Best practices when using this variable include:

  1. Keeping it enabled (set to 1) for better performance on systems with sufficient VRAM.
  2. Monitoring VRAM usage and adjusting if necessary on systems with limited VRAM.
  3. Considering the trade-off between performance and memory usage when modifying this setting.

Regarding the associated variable DistanceFieldAODownsampledBentNormal:

This variable is a member of the FFastVramConfig struct and represents the actual texture creation flags used when creating the downsampled bent normal texture for DFAO. It’s updated based on the value of the r.FastVRam.DistanceFieldAODownsampledBentNormal CVar in the FFastVramConfig::Update function.

The DistanceFieldAODownsampledBentNormal flag is used directly in the texture creation process, as seen in the FDeferredShadingSceneRenderer::RenderDistanceFieldAOScreenGrid function. It’s combined with other texture creation flags to define how the downsampled bent normal texture should be created and used.

Developers should be aware that changes to this variable will affect the creation and potentially the performance characteristics of the downsampled bent normal texture used in DFAO calculations. It’s important to ensure that any modifications to this variable are consistent with the intended rendering pipeline and performance goals of the project.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:484

Scope: file

Source code excerpt:

FASTVRAM_CVAR(DistanceFieldNormal, 1);
FASTVRAM_CVAR(DistanceFieldAOHistory, 1);
FASTVRAM_CVAR(DistanceFieldAODownsampledBentNormal, 1); 
FASTVRAM_CVAR(DistanceFieldAOBentNormal, 0); 
FASTVRAM_CVAR(DistanceFieldIrradiance, 0); 
FASTVRAM_CVAR(DistanceFieldShadows, 1);
FASTVRAM_CVAR(Distortion, 1);
FASTVRAM_CVAR(ScreenSpaceShadowMask, 1);
FASTVRAM_CVAR(VolumetricFog, 1);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldScreenGridLighting.cpp:387

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderDistanceFieldAOScreenGrid

Source code excerpt:


	{
		const FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(ConeTraceBufferSize, PF_FloatRGBA, FClearValueBinding::None, GFastVRamConfig.DistanceFieldAODownsampledBentNormal | TexCreate_RenderTargetable | TexCreate_UAV | TexCreate_ShaderResource);
		DownsampledBentNormal = GraphBuilder.CreateTexture(Desc, TEXT("DownsampledBentNormal"));
	}

	{
		const uint32 GroupSizeX = FMath::DivideAndRoundUp(ConeTraceBufferSize.X, GCombineConesSizeX);
		const uint32 GroupSizeY = FMath::DivideAndRoundUp(ConeTraceBufferSize.Y, GCombineConesSizeX);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:484

Scope: file

Source code excerpt:

FASTVRAM_CVAR(DistanceFieldNormal, 1);
FASTVRAM_CVAR(DistanceFieldAOHistory, 1);
FASTVRAM_CVAR(DistanceFieldAODownsampledBentNormal, 1); 
FASTVRAM_CVAR(DistanceFieldAOBentNormal, 0); 
FASTVRAM_CVAR(DistanceFieldIrradiance, 0); 
FASTVRAM_CVAR(DistanceFieldShadows, 1);
FASTVRAM_CVAR(Distortion, 1);
FASTVRAM_CVAR(ScreenSpaceShadowMask, 1);
FASTVRAM_CVAR(VolumetricFog, 1);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:684

Scope (from outer to inner):

file
function     void FFastVramConfig::Update

Source code excerpt:

	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldNormal, DistanceFieldNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAOHistory, DistanceFieldAOHistory);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAODownsampledBentNormal, DistanceFieldAODownsampledBentNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAOBentNormal, DistanceFieldAOBentNormal);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldIrradiance, DistanceFieldIrradiance);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldShadows, DistanceFieldShadows);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Distortion, Distortion);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ScreenSpaceShadowMask, ScreenSpaceShadowMask);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_VolumetricFog, VolumetricFog);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2834

Scope: file

Source code excerpt:

	ETextureCreateFlags DistanceFieldAOHistory;
	ETextureCreateFlags DistanceFieldAOBentNormal;
	ETextureCreateFlags DistanceFieldAODownsampledBentNormal;
	ETextureCreateFlags DistanceFieldShadows;
	ETextureCreateFlags DistanceFieldIrradiance;
	ETextureCreateFlags DistanceFieldAOConfidence;
	ETextureCreateFlags Distortion;
	ETextureCreateFlags ScreenSpaceShadowMask;
	ETextureCreateFlags VolumetricFog;