r.Water.WaterMesh.GPUQuadTree
r.Water.WaterMesh.GPUQuadTree
#Overview
name: r.Water.WaterMesh.GPUQuadTree
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Builds the water quadtree on the GPU and does indirect draws of water tiles, driven by the GPU.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.GPUQuadTree is to control the method of building and rendering water meshes in Unreal Engine 5. Specifically, it determines whether the water quadtree is built on the GPU and if water tiles are drawn using indirect draws driven by the GPU.
This setting variable is primarily used in the Water plugin, which is part of Unreal Engine’s rendering system. Based on the callsites, it’s clear that the WaterMeshComponent within the Experimental Water plugin relies on this variable.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning the GPU quadtree feature is disabled by default.
The associated variable CVarWaterMeshGPUQuadTree directly interacts with r.Water.WaterMesh.GPUQuadTree. They share the same value and purpose.
Developers must be aware that enabling this feature (by setting the value to non-zero) will change the way water meshes are processed and rendered. This could potentially impact performance and visual quality, depending on the specific use case and hardware.
Best practices when using this variable include:
- Testing the performance impact of enabling/disabling this feature in your specific game scenarios.
- Considering hardware capabilities of target platforms when deciding whether to enable this feature.
- Using this in conjunction with other water-related settings for optimal results.
Regarding the associated variable CVarWaterMeshGPUQuadTree:
- It’s an internal representation of the console variable within the C++ code.
- It’s used to retrieve the current value of the setting (e.g., CVarWaterMeshGPUQuadTree.GetValueOnGameThread()).
- When modifying the behavior controlled by this variable, developers should use this C++ variable rather than directly accessing the console variable string.
The variable is checked in the UWaterMeshComponent::RebuildWaterMesh function to determine whether to use the GPU quadtree feature when rebuilding the water mesh. This suggests that the setting can be changed at runtime, potentially allowing for dynamic optimization based on performance needs.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:35
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTree(
TEXT("r.Water.WaterMesh.GPUQuadTree"),
0,
TEXT("Builds the water quadtree on the GPU and does indirect draws of water tiles, driven by the GPU."),
ECVF_RenderThreadSafe
);
/** Debug CVars */
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshGPUQuadTree
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:34
Scope: file
Source code excerpt:
ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTree(
TEXT("r.Water.WaterMesh.GPUQuadTree"),
0,
TEXT("Builds the water quadtree on the GPU and does indirect draws of water tiles, driven by the GPU."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:268
Scope (from outer to inner):
file
function void UWaterMeshComponent::RebuildWaterMesh
Source code excerpt:
}
const bool bIsGPUQuadTree = CVarWaterMeshGPUQuadTree.GetValueOnGameThread() != 0;
// This resets the tree to an initial state, ready for node insertion
WaterQuadTree.InitTree(WaterWorldBox, InTileSize, InExtentInTiles, bIsGPUQuadTree);
UsedMaterials.Empty();