r.DistanceFields.Debug.ResizeAtlasEveryFrame
r.DistanceFields.Debug.ResizeAtlasEveryFrame
#Overview
name: r.DistanceFields.Debug.ResizeAtlasEveryFrame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to resize the Distance Field atlas every frame, which is useful for debugging.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DistanceFields.Debug.ResizeAtlasEveryFrame is to control whether the Distance Field atlas is resized every frame for debugging purposes in the Unreal Engine rendering system.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the Distance Field rendering subsystem. It’s referenced in the DistanceFieldStreaming.cpp file, which suggests it’s part of the Distance Field streaming functionality.
The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default.
The associated variable CVarResizeAtlasEveryFrame directly interacts with r.DistanceFields.Debug.ResizeAtlasEveryFrame. They share the same value and purpose.
Developers must be aware that enabling this variable (setting it to a non-zero value) will cause the Distance Field atlas to be resized every frame. This can have significant performance implications and should only be used for debugging purposes.
Best practices when using this variable include:
- Only enable it when actively debugging Distance Field atlas issues.
- Disable it immediately after debugging to avoid unnecessary performance overhead.
- Be cautious when using it in production builds, as it may severely impact performance.
Regarding the associated variable CVarResizeAtlasEveryFrame:
The purpose of CVarResizeAtlasEveryFrame is identical to r.DistanceFields.Debug.ResizeAtlasEveryFrame. It’s the actual C++ variable that controls the behavior within the engine code.
This variable is used in the FDistanceFieldSceneData::ResizeBrickAtlasIfNeeded function to determine whether the Distance Field brick atlas should be resized every frame. If the variable is set to a non-zero value, the atlas will be resized regardless of whether it’s necessary based on the current dimensions.
The value of CVarResizeAtlasEveryFrame is accessed using the GetValueOnRenderThread() method, indicating that it’s designed to be safely read from the render thread.
Developers should be aware that modifying this variable at runtime will immediately affect the Distance Field rendering system’s behavior. It’s important to use this variable judiciously and only when necessary for debugging purposes.
Best practices for CVarResizeAtlasEveryFrame are the same as for r.DistanceFields.Debug.ResizeAtlasEveryFrame, as they are essentially two interfaces to the same functionality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:73
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarResizeAtlasEveryFrame(
TEXT("r.DistanceFields.Debug.ResizeAtlasEveryFrame"),
0,
TEXT("Whether to resize the Distance Field atlas every frame, which is useful for debugging."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDebugForceNumMips(
TEXT("r.DistanceFields.Debug.ForceNumMips"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarResizeAtlasEveryFrame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:72
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarResizeAtlasEveryFrame(
TEXT("r.DistanceFields.Debug.ResizeAtlasEveryFrame"),
0,
TEXT("Whether to resize the Distance Field atlas every frame, which is useful for debugging."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDebugForceNumMips(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:1002
Scope (from outer to inner):
file
function FRDGTexture* FDistanceFieldSceneData::ResizeBrickAtlasIfNeeded
Source code excerpt:
const FIntVector DesiredBrickTextureDimensionsInBricks = FIntVector(BrickAtlasSizeXYInBricks, BrickAtlasSizeXYInBricks, DesiredZSizeInBricks);
const bool bResizeAtlasEveryFrame = CVarResizeAtlasEveryFrame.GetValueOnRenderThread() != 0;
if (!DistanceFieldBrickVolumeTexture
|| DistanceFieldBrickVolumeTexture->GetDesc().GetSize() != DesiredBrickTextureDimensionsInBricks * DistanceField::BrickSize
|| bResizeAtlasEveryFrame)
{
const FRDGTextureDesc BrickVolumeTextureDesc = FRDGTextureDesc::Create3D(