r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide
r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide
#Overview
name: r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of quads per side of each tile mesh used to draw the water surface. A lower number results in more draw calls, a higher number in wasted VS invocations. Default: 8
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide is to control the number of quads per side of each tile mesh used to draw the water surface in Unreal Engine 5’s water rendering system.
This setting variable is primarily used in the Water plugin, specifically in the water mesh rendering subsystem. It’s part of the experimental Water plugin in Unreal Engine 5.
The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime. It’s initialized with a default value of 8 in the source code.
This variable interacts closely with the water mesh rendering system, particularly in determining the balance between draw calls and vertex shader invocations. A lower value results in more draw calls, while a higher value may lead to wasted vertex shader invocations.
Developers should be aware that this variable directly impacts rendering performance and visual quality of water surfaces. Adjusting this value can help optimize the water rendering for specific scenes or hardware configurations.
Best practices when using this variable include:
- Experimenting with different values to find the optimal balance between performance and visual quality for your specific use case.
- Considering the target hardware capabilities when setting this value.
- Monitoring the impact on draw calls and vertex shader invocations when adjusting this value.
The associated variable CVarWaterMeshGPUQuadTreeNumQuads is the actual console variable that stores and manages the value of r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide. It’s defined using the TAutoConsoleVariable template, which allows for easy integration with Unreal Engine’s console variable system.
This associated variable is used in the FWaterMeshSceneProxy constructor to determine the number of quads per indirect draw tile. It’s clamped between 2 and 128, and rounded up to the nearest power of two.
When working with CVarWaterMeshGPUQuadTreeNumQuads, developers should:
- Use the GetValueOnGameThread() method to safely access its value from the game thread.
- Be aware that changes to this variable will affect the water mesh generation and rendering in real-time.
- Consider exposing this variable in debug or graphics settings menus for easy tuning during development or for allowing end-users to optimize performance on their hardware.
#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:65
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeNumQuads(
TEXT("r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide"), 8,
TEXT("Number of quads per side of each tile mesh used to draw the water surface. A lower number results in more draw calls, a higher number in wasted VS invocations. Default: 8"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadInstanceDataAllocMult(
TEXT("r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult"), 1.0f,
TEXT("Multiplier to apply to the number of tiles in the quadtree at LOD0. The derived number is how many slots for water quad mesh instance data are allocated. Default: 1.0, Min: 0.0, Max: 8.0"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshGPUQuadTreeNumQuads
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:64
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeNumQuads(
TEXT("r.Water.WaterMesh.GPUQuadTree.NumQuadsPerTileSide"), 8,
TEXT("Number of quads per side of each tile mesh used to draw the water surface. A lower number results in more draw calls, a higher number in wasted VS invocations. Default: 8"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadInstanceDataAllocMult(
TEXT("r.Water.WaterMesh.GPUQuadTree.InstanceDataAllocMult"), 1.0f,
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:178
Scope (from outer to inner):
file
function FWaterMeshSceneProxy::FWaterMeshSceneProxy
Source code excerpt:
int32 NumQuads = (int32)FMath::Pow(2.0f, (float)Component->GetTessellationFactor());
NumQuadsLOD0 = NumQuads;
NumQuadsPerIndirectDrawTile = FMath::Min((int32)FMath::RoundUpToPowerOfTwo(FMath::Clamp(CVarWaterMeshGPUQuadTreeNumQuads.GetValueOnGameThread(), 2, 128)), NumQuadsLOD0);
const bool bIsGPUQuadTree = WaterQuadTree.IsGPUQuadTree();
// Initialize Z bounds needed for GPU driven rendering
if (bIsGPUQuadTree)
{