r.Water.WaterMesh.ShowTileBounds
r.Water.WaterMesh.ShowTileBounds
#Overview
name: r.Water.WaterMesh.ShowTileBounds
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Shows the tile bounds with optional color modes: 0 is disabled, 1 is by water body type, 2 is by LOD, 3 is by density index
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.ShowTileBounds is to provide a debugging visualization tool for the water mesh system in Unreal Engine 5. It allows developers to visually inspect the tile bounds of the water mesh with different color modes representing various properties.
This setting variable is primarily used in the Water plugin, specifically within the water mesh rendering system. It is referenced in the WaterMeshSceneProxy.cpp file, which is part of the experimental Water plugin’s runtime module.
The value of this variable is set through a console variable (CVarWaterMeshShowTileBounds) with default value 0. It can be changed at runtime using console commands or through code.
The variable interacts closely with the water mesh rendering system, particularly in the FWaterMeshSceneProxy::GetDynamicMeshElements function. It’s used to control the debug visualization of water tile bounds and is passed to the water quad tree traversal parameters.
Developers should be aware that:
- This is a debugging tool and should not be enabled in release builds.
- It has performance implications when enabled, as it adds additional rendering overhead.
- The variable accepts values 0-3, each representing a different visualization mode.
Best practices for using this variable include:
- Use it temporarily during development and debugging phases.
- Combine it with other water mesh debugging tools for comprehensive analysis.
- Be mindful of the performance impact when enabled, especially in complex scenes.
Regarding the associated variable CVarWaterMeshShowTileBounds:
The purpose of CVarWaterMeshShowTileBounds is to serve as the actual console variable that controls the r.Water.WaterMesh.ShowTileBounds setting. It’s defined using the TAutoConsoleVariable template class, which allows it to be easily accessed and modified through the console or code.
This variable is used directly in the Water plugin’s rendering code to determine whether and how to display the water mesh tile bounds. It’s primarily accessed in the GetDynamicMeshElements function of the FWaterMeshSceneProxy class.
The value of this variable is set when it’s defined, with a default value of 0. It can be changed at runtime through console commands or programmatically.
CVarWaterMeshShowTileBounds interacts closely with the water mesh rendering system and is often used in conjunction with other debugging variables like CVarWaterMeshShowTileBoundsForeground.
Developers should be aware that:
- This variable is thread-safe for render thread access (ECVF_RenderThreadSafe).
- Changes to this variable will immediately affect the debug visualization.
Best practices for using this variable include:
- Access it using GetValueOnRenderThread() when in render thread context.
- Consider exposing it in debug UIs for easy toggling during development.
- Ensure it’s disabled in shipping builds to avoid any performance overhead.
#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:114
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBounds(
TEXT("r.Water.WaterMesh.ShowTileBounds"),
0,
TEXT("Shows the tile bounds with optional color modes: 0 is disabled, 1 is by water body type, 2 is by LOD, 3 is by density index"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBoundsForeground(
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshShowTileBounds
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:113
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarWaterMeshShowTileBounds(
TEXT("r.Water.WaterMesh.ShowTileBounds"),
0,
TEXT("Shows the tile bounds with optional color modes: 0 is disabled, 1 is by water body type, 2 is by LOD, 3 is by density index"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:487
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
WaterQuadTreeGPUTraverseParams.LeafSize = WaterQuadTree.GetLeafSize();
WaterQuadTreeGPUTraverseParams.LODScale = LODScale;
WaterQuadTreeGPUTraverseParams.DebugShowTile = CVarWaterMeshShowTileBounds.GetValueOnRenderThread();
WaterQuadTreeGPUTraverseParams.bWithWaterSelectionSupport = WITH_WATER_SELECTION_SUPPORT != 0;
WaterQuadTreeGPUTraverseParams.bLODMorphingEnabled = !!CVarWaterMeshLODMorphEnabled.GetValueOnRenderThread();
bNeedToTraverseGPUQuadTree = true;
}
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:684
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
//Debug
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);
}