r.Water.WaterMesh.ShowTileBounds.DrawForeground

r.Water.WaterMesh.ShowTileBounds.DrawForeground

#Overview

name: r.Water.WaterMesh.ShowTileBounds.DrawForeground

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.ShowTileBounds.DrawForeground is to control the visibility of water mesh tile bounds in the foreground, even when they are occluded. This setting is part of the water rendering system in Unreal Engine 5.

This setting variable is primarily used in the Experimental Water plugin, specifically within the Runtime module. It’s referenced in the WaterMeshSceneProxy.cpp file, which suggests it’s closely tied to the water mesh rendering process.

The value of this variable is set through a console variable (CVarWaterMeshShowTileBoundsForeground) using the TAutoConsoleVariable template. It’s initialized with a default value of 0, meaning the feature is disabled by default.

This variable interacts with another variable named CVarWaterMeshShowTileBounds. While CVarWaterMeshShowTileBounds controls whether to show tile bounds in general, r.Water.WaterMesh.ShowTileBounds.DrawForeground specifically determines if these bounds should be drawn in the foreground, making them visible even when occluded.

Developers should be aware that this is a render thread safe variable (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread. It’s primarily used for debugging purposes, so it should be used cautiously in production builds.

Best practices when using this variable include:

  1. Use it primarily for debugging and development purposes.
  2. Be aware of potential performance impacts when enabled, especially in complex water scenes.
  3. Use in conjunction with other water mesh debugging tools for comprehensive analysis.

Regarding the associated variable CVarWaterMeshShowTileBoundsForeground:

The purpose of CVarWaterMeshShowTileBoundsForeground is to provide a programmatic way to control the r.Water.WaterMesh.ShowTileBounds.DrawForeground setting within the engine’s C++ code.

This variable is used in the same Experimental Water plugin and Runtime module as the console variable. It’s defined and used in the WaterMeshSceneProxy.cpp file.

The value of this variable is set when the console variable is initialized, and it can be accessed using the GetValueOnRenderThread() method.

CVarWaterMeshShowTileBoundsForeground interacts directly with the r.Water.WaterMesh.ShowTileBounds.DrawForeground console variable, essentially serving as its C++ representation.

Developers should be aware that this variable is of type TAutoConsoleVariable, which means it’s thread-safe and can be accessed from multiple threads without additional synchronization.

Best practices for using CVarWaterMeshShowTileBoundsForeground include:

  1. Use GetValueOnRenderThread() when accessing its value from the render thread.
  2. Remember that changes to this variable will affect the visualization of water mesh tile bounds in the engine.
  3. Use it in conjunction with other debugging variables like CVarWaterMeshShowTileBounds for comprehensive water mesh debugging.

#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:121

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBoundsForeground(
	TEXT("r.Water.WaterMesh.ShowTileBounds.DrawForeground"),
	0,
	TEXT("Shows all tile bounds, even occluded ones by drawing into the foreground"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarWaterMeshPreAllocStagingInstanceMemory(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBoundsForeground(
	TEXT("r.Water.WaterMesh.ShowTileBounds.DrawForeground"),
	0,
	TEXT("Shows all tile bounds, even occluded ones by drawing into the foreground"),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     void FWaterMeshSceneProxy::GetDynamicMeshElements

Source code excerpt:

			TraversalDesc.DebugPDI = Collector.GetPDI(ViewIndex);
			TraversalDesc.DebugShowTile = CVarWaterMeshShowTileBounds.GetValueOnRenderThread();
			TraversalDesc.bDebugDrawIntoForeground = CVarWaterMeshShowTileBoundsForeground.GetValueOnRenderThread() != 0;
#endif
			WaterQuadTree.BuildWaterTileInstanceData(TraversalDesc, WaterInstanceData);

			HistoricalMaxViewInstanceCount = FMath::Max(HistoricalMaxViewInstanceCount, WaterInstanceData.InstanceCount);
		}
	}