r.Water.WaterMesh.ForceRebuildMeshPerFrame
r.Water.WaterMesh.ForceRebuildMeshPerFrame
#Overview
name: r.Water.WaterMesh.ForceRebuildMeshPerFrame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Force rebuilding the entire mesh each frame
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.ForceRebuildMeshPerFrame is to control the rebuilding of water meshes in the Unreal Engine’s water rendering system. This setting variable is used to force the entire water mesh to be rebuilt every frame, which can be useful for debugging or testing purposes.
This setting variable is primarily used in the Experimental Water plugin, specifically within the WaterMeshComponent. The Water plugin is responsible for rendering realistic water surfaces in Unreal Engine 5.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0, meaning that by default, the water mesh is not forced to rebuild every frame.
The associated variable CVarWaterMeshForceRebuildMeshPerFrame interacts directly with r.Water.WaterMesh.ForceRebuildMeshPerFrame. They share the same value and purpose.
Developers must be aware that enabling this variable (setting it to 1) will force the water mesh to rebuild every frame, which can have a significant performance impact. This should generally only be used for debugging or testing purposes, not in production builds.
Best practices when using this variable include:
- Keep it disabled (set to 0) for normal gameplay and production builds.
- Use it temporarily when debugging issues related to water mesh generation or rendering.
- Be aware of the performance implications when enabled.
- Use in conjunction with other water-related debug settings for comprehensive testing.
Regarding the associated variable CVarWaterMeshForceRebuildMeshPerFrame:
The purpose of CVarWaterMeshForceRebuildMeshPerFrame is identical to r.Water.WaterMesh.ForceRebuildMeshPerFrame. It’s an internal representation of the console variable within the C++ code.
This variable is used within the UWaterMeshComponent::Update function to determine if the water mesh needs to be rebuilt. It’s checked alongside other conditions such as CVarWaterMeshShowTileGenerationGeometry and various LOD (Level of Detail) parameters.
The value of this variable is retrieved using the GetValueOnGameThread() method, which suggests that it’s designed to be thread-safe for use in game thread operations.
Developers should treat this variable the same way as r.Water.WaterMesh.ForceRebuildMeshPerFrame. It’s an implementation detail of how the console variable is accessed within the engine code, but its purpose and usage considerations remain the same.
#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:50
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshForceRebuildMeshPerFrame(
TEXT("r.Water.WaterMesh.ForceRebuildMeshPerFrame"),
0,
TEXT("Force rebuilding the entire mesh each frame"),
ECVF_Default
);
TAutoConsoleVariable<int32> CVarWaterMeshEnabled(
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshForceRebuildMeshPerFrame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:49
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarWaterMeshForceRebuildMeshPerFrame(
TEXT("r.Water.WaterMesh.ForceRebuildMeshPerFrame"),
0,
TEXT("Force rebuilding the entire mesh each frame"),
ECVF_Default
);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:825
Scope (from outer to inner):
file
function void UWaterMeshComponent::Update
Source code excerpt:
if (bNeedsRebuild
|| !!CVarWaterMeshShowTileGenerationGeometry.GetValueOnGameThread()
|| !!CVarWaterMeshForceRebuildMeshPerFrame.GetValueOnGameThread()
|| (NewLODCountBias != LODCountBiasScalability)
|| (NewTessFactorBias != TessFactorBiasScalability)
|| (NewLODScaleBias != LODScaleBiasScalability))
{
LODCountBiasScalability = NewLODCountBias;
TessFactorBiasScalability = NewTessFactorBias;