Landscape.DebugViewMode

Landscape.DebugViewMode

#Overview

name: Landscape.DebugViewMode

This variable is created as a Console Variable (cvar).

It is referenced in 13 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Landscape.DebugViewMode is to control the visualization mode of the landscape rendering system in Unreal Engine. It allows developers and artists to switch between different debug views to inspect various aspects of the landscape.

This setting variable is primarily used in the Landscape subsystem of Unreal Engine. It’s referenced in both the runtime Landscape module and the LandscapeEditor module, indicating its importance in both game runtime and editor functionality.

The value of this variable is set through a console command, as evident from the FAutoConsoleVariableRef declaration. It can be changed at runtime using the console command “Landscape.DebugViewMode”.

The associated variable GLandscapeViewMode directly interacts with Landscape.DebugViewMode. They share the same value, with GLandscapeViewMode being the actual int32 variable used throughout the code to determine the current view mode.

Developers should be aware that changing this variable affects the rendering of landscapes in both the editor and at runtime (if the debug code is included in the build). It’s primarily intended for debugging and development purposes, not for use in shipping games.

Best practices when using this variable include:

  1. Use it during development and debugging phases to inspect different aspects of landscape rendering.
  2. Be cautious when changing it at runtime, as it can affect performance and visual output.
  3. Remember to set it back to normal (0) after debugging to ensure standard landscape rendering.

Regarding the associated variable GLandscapeViewMode:

The purpose of GLandscapeViewMode is to store the current landscape view mode throughout the engine’s codebase. It’s an int32 that corresponds to the ELandscapeViewMode enum values.

This variable is used across multiple Landscape-related systems, including rendering, editor functionality, and debug visualizations. It’s referenced in landscape rendering code, editor customizations, and landscape editing tools.

The value of GLandscapeViewMode is set either through the console variable Landscape.DebugViewMode or programmatically in the editor code.

GLandscapeViewMode interacts directly with Landscape.DebugViewMode, effectively serving as its in-code representation.

Developers should be aware that changes to GLandscapeViewMode will affect landscape rendering and editor functionality. It’s a global variable, so changes will impact all landscapes in the scene.

Best practices for GLandscapeViewMode include:

  1. Use the provided editor functions to change the view mode rather than modifying GLandscapeViewMode directly.
  2. Be aware of its impact on performance and visual output when used in non-debug scenarios.
  3. Always ensure it’s set to the appropriate value (typically Normal) before building for release.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:229

Scope: file

Source code excerpt:

LANDSCAPE_API int32 GLandscapeViewMode = ELandscapeViewMode::Normal;
FAutoConsoleVariableRef CVarLandscapeDebugViewMode(
	TEXT("Landscape.DebugViewMode"),
	GLandscapeViewMode,
	TEXT("Change the view mode of the landscape rendering. Valid Input: 0 = Normal, 2 = DebugLayer, 3 = LayerDensity, 4 = LayerUsage, 5 = LOD Distribution, 6 = WireframeOnTop, 7 = LayerContribution"),
	ECVF_Cheat
);
#endif

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdMode.cpp:721

Scope (from outer to inner):

file
function     void FEdModeLandscape::Exit

Source code excerpt:

	// Save UI settings to config file
	UISettings->Save();
	GLandscapeViewMode = ELandscapeViewMode::Normal;
	GLandscapeEditRenderMode = ELandscapeEditRenderMode::None;
	GLandscapeEditModeActive = false;

	CurrentGizmoActor = nullptr;

	GEditor->SelectNone(false, true);

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorDetailCustomization_TargetLayers.cpp:1412

Scope (from outer to inner):

file
function     FSlateColor FLandscapeEditorCustomNodeBuilder_TargetLayers::GetLayerUsageDebugColor

Source code excerpt:

FSlateColor FLandscapeEditorCustomNodeBuilder_TargetLayers::GetLayerUsageDebugColor(const TSharedRef<FLandscapeTargetListInfo> Target)
{
	if (GLandscapeViewMode == ELandscapeViewMode::LayerUsage && Target->TargetType != ELandscapeToolTargetType::Heightmap && ensure(Target->LayerInfoObj.IsValid()))
	{
		return FSlateColor(Target->LayerInfoObj->LayerUsageDebugColor);
	}
	return FSlateColor(FLinearColor(0, 0, 0, 0));
}

EVisibility FLandscapeEditorCustomNodeBuilder_TargetLayers::GetDebugModeLayerUsageVisibility(const TSharedRef<FLandscapeTargetListInfo> Target)
{
	if (GLandscapeViewMode == ELandscapeViewMode::LayerUsage && Target->TargetType != ELandscapeToolTargetType::Heightmap && Target->LayerInfoObj.IsValid())
	{
		return EVisibility::Visible;
	}

	return EVisibility::Collapsed;
}

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorDetailCustomization_TargetLayers.cpp:1431

Scope (from outer to inner):

file
function     EVisibility FLandscapeEditorCustomNodeBuilder_TargetLayers::GetDebugModeLayerUsageVisibility_Invert

Source code excerpt:

EVisibility FLandscapeEditorCustomNodeBuilder_TargetLayers::GetDebugModeLayerUsageVisibility_Invert(const TSharedRef<FLandscapeTargetListInfo> Target)
{
	if (GLandscapeViewMode == ELandscapeViewMode::LayerUsage && Target->TargetType != ELandscapeToolTargetType::Heightmap && Target->LayerInfoObj.IsValid())
	{
		return EVisibility::Collapsed;
	}

	return EVisibility::Visible;
}

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorDetailCustomization_TargetLayers.cpp:1473

Scope (from outer to inner):

file
function     EVisibility FLandscapeEditorCustomNodeBuilder_TargetLayers::GetDebugModeColorChannelVisibility

Source code excerpt:

EVisibility FLandscapeEditorCustomNodeBuilder_TargetLayers::GetDebugModeColorChannelVisibility(const TSharedRef<FLandscapeTargetListInfo> Target)
{
	if (GLandscapeViewMode == ELandscapeViewMode::DebugLayer && Target->TargetType != ELandscapeToolTargetType::Heightmap && Target->LayerInfoObj.IsValid())
	{
		return EVisibility::Visible;
	}

	return EVisibility::Collapsed;
}

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorModule.cpp:256

Scope (from outer to inner):

file
class        class FLandscapeEditorModule : public ILandscapeEditorModule, public ILandscapeEditorServices
function     static void ChangeLandscapeViewMode

Source code excerpt:

	static void ChangeLandscapeViewMode(ELandscapeViewMode::Type ViewMode)
	{
		if (ViewMode != GLandscapeViewMode)
		{
			GLandscapeViewMode = ViewMode;

			if (GEditor)
			{
				GEditor->RedrawAllViewports(/*bInvalidateHitProxies =*/false);
			}
		}

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorModule.cpp:269

Scope (from outer to inner):

file
class        class FLandscapeEditorModule : public ILandscapeEditorModule, public ILandscapeEditorServices
function     static bool IsLandscapeViewModeSelected

Source code excerpt:

	static bool IsLandscapeViewModeSelected(ELandscapeViewMode::Type ViewMode)
	{
		return GLandscapeViewMode == ViewMode;
	}

	/**
	 * ILandscapeEditorModule implementation
	 */
	virtual void RegisterHeightmapFileFormat(TSharedRef<ILandscapeHeightmapFileFormat> FileFormat) override

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:8125

Scope (from outer to inner):

file
function     void ALandscape::MonitorLandscapeEdModeChanges

Source code excerpt:

{
	bool bRequiredEditingClientFullUpdate = false;
	if (LandscapeEdModeInfo.ViewMode != GLandscapeViewMode)
	{
		LandscapeEdModeInfo.ViewMode = GLandscapeViewMode;
		bRequiredEditingClientFullUpdate = true;
	}

	ELandscapeToolTargetType NewValue = LandscapeEdMode ? LandscapeEdMode->GetLandscapeToolTargetType() : ELandscapeToolTargetType::Invalid;
	if (LandscapeEdModeInfo.ToolTarget != NewValue)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:227

Scope: file

Source code excerpt:


#if WITH_EDITOR
LANDSCAPE_API int32 GLandscapeViewMode = ELandscapeViewMode::Normal;
FAutoConsoleVariableRef CVarLandscapeDebugViewMode(
	TEXT("Landscape.DebugViewMode"),
	GLandscapeViewMode,
	TEXT("Change the view mode of the landscape rendering. Valid Input: 0 = Normal, 2 = DebugLayer, 3 = LayerDensity, 4 = LayerUsage, 5 = LOD Distribution, 6 = WireframeOnTop, 7 = LayerContribution"),
	ECVF_Cheat
);
#endif

#if RHI_RAYTRACING

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:2047

Scope (from outer to inner):

file
function     FPrimitiveViewRelevance FLandscapeComponentSceneProxy::GetViewRelevance

Source code excerpt:

			}

			if (GLandscapeViewMode == ELandscapeViewMode::LayerContribution)
			{
				Result.bDynamicRelevance = true;
				ToolRelevance |= GColorMaskRegionMaterial->GetRelevance_Concurrent(FeatureLevel);
			}

			if (CVarLandscapeShowDirty.GetValueOnRenderThread() && GLandscapeDirtyMaterial)

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:2086

Scope (from outer to inner):

file
function     FPrimitiveViewRelevance FLandscapeComponentSceneProxy::GetViewRelevance

Source code excerpt:

#if WITH_EDITOR
		(IsSelected() && !GLandscapeEditModeActive) ||
		(GLandscapeViewMode != ELandscapeViewMode::Normal) ||
		(CVarLandscapeShowDirty.GetValueOnAnyThread() && GLandscapeDirtyMaterial) ||
		(GetViewLodOverride(*View, LandscapeKey) >= 0)
#else
		IsSelected() ||
		(View->CustomRenderPass && GetViewLodOverride(*View, LandscapeKey) >= 0)
#endif

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:2597

Scope: file

Source code excerpt:

			// Render the landscape component
#if WITH_EDITOR
			switch (GLandscapeViewMode)
			{
			case ELandscapeViewMode::DebugLayer:
			{
				if (GLayerDebugColorMaterial)
				{
					auto DebugColorMaterialInstance = new FLandscapeDebugMaterialRenderProxy(GLayerDebugColorMaterial->GetRenderProxy(),

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Public/LandscapeRender.h:64

Scope: file

Source code excerpt:

}

extern LANDSCAPE_API int32 GLandscapeViewMode;

namespace ELandscapeEditRenderMode
{
	enum Type
	{
		None = 0x0,