r.Water.WaterMesh.ShowLODLevels

r.Water.WaterMesh.ShowLODLevels

#Overview

name: r.Water.WaterMesh.ShowLODLevels

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Water.WaterMesh.ShowLODLevels is to provide a visual debugging tool for the water mesh system in Unreal Engine 5. It allows developers to visualize the LOD (Level of Detail) levels of the water mesh as concentric squares around the observer position at height 0.

This setting variable is primarily used in the Water plugin, which is part of the rendering system in Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized within the WaterMeshSceneProxy component of the Water plugin.

The value of this variable is set through a console command. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default.

The associated variable CVarWaterMeshShowLODLevels interacts directly with r.Water.WaterMesh.ShowLODLevels. They share the same value and purpose.

Developers must be aware that this variable is intended for debugging purposes only. It should not be enabled in shipping or test builds, as evidenced by the #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) conditional compilation directive.

Best practices when using this variable include:

  1. Only enable it during development and debugging phases.
  2. Use it in conjunction with other water mesh debugging tools for a comprehensive understanding of the LOD system.
  3. Remember to disable it before finalizing the project for release.

Regarding the associated variable CVarWaterMeshShowLODLevels:

The purpose of CVarWaterMeshShowLODLevels is identical to r.Water.WaterMesh.ShowLODLevels. It’s the C++ representation of the console variable used within the engine’s code.

This variable is used in the Water plugin, specifically in the WaterMeshSceneProxy component. It’s checked in the GetDynamicMeshElements function to determine whether to render the LOD level visualization.

The value of CVarWaterMeshShowLODLevels is set when r.Water.WaterMesh.ShowLODLevels is set via console command.

CVarWaterMeshShowLODLevels interacts directly with the rendering logic of the water mesh LOD system. When enabled, it triggers the rendering of concentric squares representing LOD levels.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which means it’s designed for efficient use in rendering operations.

Best practices for CVarWaterMeshShowLODLevels are the same as for r.Water.WaterMesh.ShowLODLevels, with an additional note to be cautious about potential performance impacts when enabled, as it adds additional rendering operations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:107

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarWaterMeshShowLODLevels(
	TEXT("r.Water.WaterMesh.ShowLODLevels"),
	0,
	TEXT("Shows the LOD levels as concentric squares around the observer position at height 0"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBounds(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:106

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarWaterMeshShowLODLevels(
	TEXT("r.Water.WaterMesh.ShowLODLevels"),
	0,
	TEXT("Shows the LOD levels as concentric squares around the observer position at height 0"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:637

Scope (from outer to inner):

file
function     void FWaterMeshSceneProxy::GetDynamicMeshElements

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			if (CVarWaterMeshShowLODLevels.GetValueOnRenderThread())
			{
				for (int32 i = WaterLODParams.LowestLOD; i < WaterQuadTree.GetTreeDepth(); i++)
				{
					float LODDist = FWaterQuadTree::GetLODDistance(i, LODScale);
					FVector Orig = FVector(FVector2D(ObserverPosition), WaterLODParams.WaterHeightForLOD);