r.Editor.NewLevelGrid
r.Editor.NewLevelGrid
#Overview
name: r.Editor.NewLevelGrid
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Wether to show the new editor level grid\n0: off\n1: Analytical Antialiasing\n2: Texture based(default)
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Editor.NewLevelGrid is to control the display of the new editor level grid in Unreal Engine 5. It is primarily used for rendering and visualization in the editor environment.
This setting variable is primarily utilized by the UnrealEd module, specifically within the editor components and rendering system. It affects how the level grid is displayed in the Unreal Editor.
The value of this variable is set through a console variable (CVar) named CVarEditorNewLevelGrid. It is initialized with a default value of 2, which corresponds to using a texture-based grid.
The variable interacts with several other components:
- It determines which material is used for the level grid (texture-based or analytical antialiasing).
- It affects the creation and updating of Material Instance Dynamics (MIDs) for the grid.
- It influences the grid drawing behavior in the FEditorCommonDrawHelper::Draw function.
Developers should be aware that:
- The variable has three possible values: 0 (off), 1 (analytical antialiasing), and 2 (texture-based, default).
- The choice between texture-based and analytical antialiasing can affect performance and visual quality.
- The grid display is automatically disabled for non-perspective projections.
Best practices when using this variable include:
- Consider performance implications when choosing between texture-based and analytical antialiasing.
- Test the grid appearance in different view modes to ensure it’s visible and not interfering with other elements.
- Be cautious when modifying this value at runtime, as it may affect editor performance.
Regarding the associated variable CVarEditorNewLevelGrid:
This is the actual console variable that stores and manages the r.Editor.NewLevelGrid setting. It is defined using TAutoConsoleVariable
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:16
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarEditorNewLevelGrid(
TEXT("r.Editor.NewLevelGrid"),
2,
TEXT("Wether to show the new editor level grid\n")
TEXT("0: off\n")
TEXT("1: Analytical Antialiasing\n")
TEXT("2: Texture based(default)"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarEditorNewLevelGrid
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:15
Scope: file
Source code excerpt:
#include "GameFramework/WorldSettings.h"
static TAutoConsoleVariable<int32> CVarEditorNewLevelGrid(
TEXT("r.Editor.NewLevelGrid"),
2,
TEXT("Wether to show the new editor level grid\n")
TEXT("0: off\n")
TEXT("1: Analytical Antialiasing\n")
TEXT("2: Texture based(default)"),
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:93
Scope (from outer to inner):
file
function UMaterial* FGridWidget::GetActiveLevelGridMaterial
Source code excerpt:
UMaterial* FGridWidget::GetActiveLevelGridMaterial()
{
bool bUseTextureSolution = CVarEditorNewLevelGrid.GetValueOnGameThread() > 1;
if (bUseTextureSolution)
{
return TextureBasedLevelGridMaterial.LoadSynchronous();
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:105
Scope (from outer to inner):
file
function UMaterialInstanceDynamic* FGridWidget::GetActiveLevelGridMID
Source code excerpt:
UMaterialInstanceDynamic* FGridWidget::GetActiveLevelGridMID()
{
bool bUseTextureSolution = CVarEditorNewLevelGrid.GetValueOnGameThread() > 1;
UMaterial* BaseGridMat = GetActiveLevelGridMaterial();
if (!LevelGridMaterialInst || LevelGridMaterialInst->Parent != BaseGridMat)
{
LevelGridMaterialInst = UMaterialInstanceDynamic::Create(BaseGridMat, nullptr);
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:393
Scope (from outer to inner):
file
function void FEditorCommonDrawHelper::Draw
Source code excerpt:
if( View->Family->EngineShowFlags.Grid && bDrawGrid)
{
bool bShouldUseNewLevelGrid = CVarEditorNewLevelGrid.GetValueOnGameThread() != 0;
if(!View->IsPerspectiveProjection())
{
// 3D looks better with the old grid (no thick lines)
bShouldUseNewLevelGrid = false;
}