r.Water.WaterMesh.LODMorphEnabled
r.Water.WaterMesh.LODMorphEnabled
#Overview
name: r.Water.WaterMesh.LODMorphEnabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If the smooth LOD morph is enabled. Turning this off may cause slight popping between LOD levels but will skip the calculations in the vertex shader, making it cheaper
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.LODMorphEnabled is to control the smooth LOD morphing for water meshes in Unreal Engine 5’s water rendering system. This setting variable is used to enable or disable the smooth transition between different levels of detail (LODs) for water meshes.
- The water rendering system in Unreal Engine 5’s experimental Water plugin relies on this setting variable.
- The value of this variable is set through the console variable system, with a default value of 1 (enabled).
- It interacts closely with the associated variable CVarWaterMeshLODMorphEnabled, which is the actual TAutoConsoleVariable object that stores and manages the setting.
- Developers must be aware that enabling this variable may increase vertex shader calculations, while disabling it may cause slight popping between LOD levels but improve performance.
- Best practices when using this variable include:
- Enabling it for higher visual quality in scenes where water is a prominent feature.
- Disabling it for performance-critical scenarios or on lower-end hardware.
- Testing both enabled and disabled states to find the right balance between visual quality and performance for your specific project.
Regarding the associated variable CVarWaterMeshLODMorphEnabled:
The purpose of CVarWaterMeshLODMorphEnabled is to provide a programmatic interface for the r.Water.WaterMesh.LODMorphEnabled setting within the engine’s code.
- It is used in the Water plugin’s runtime module, specifically in the water mesh rendering system.
- The value is set when the engine initializes the console variable system.
- It interacts directly with the r.Water.WaterMesh.LODMorphEnabled console command, sharing the same value.
- Developers should be aware that this variable is used in performance-critical rendering code, so changing its value at runtime may have immediate effects on water rendering.
- Best practices for using this variable include:
- Accessing its value using GetValueOnRenderThread() when in render thread code.
- Considering its impact on shader complexity and performance when designing water rendering features.
- Using it in conjunction with other water rendering settings to achieve the desired balance of quality and performance.
#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:30
Scope: file
Source code excerpt:
/** Scalability CVars */
static TAutoConsoleVariable<int32> CVarWaterMeshLODMorphEnabled(
TEXT("r.Water.WaterMesh.LODMorphEnabled"), 1,
TEXT("If the smooth LOD morph is enabled. Turning this off may cause slight popping between LOD levels but will skip the calculations in the vertex shader, making it cheaper"),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeSuperSampling(
TEXT("r.Water.WaterMesh.GPUQuadTree.SuperSampling"), 2,
TEXT("Rasterizes water meshes into the GPU water quadtree at a higher resolution, reducing missing water tile artifacts near the edges of water bodies. Default: 2, Min: 1, Max : 8"),
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterVertexFactory.cpp:117
Scope (from outer to inner):
file
class class TWaterVertexFactoryShaderParameters : public FVertexFactoryShaderParameters
function void GetElementShaderBindings
Source code excerpt:
ShaderBindings.Add(QuadTreePositionParameter, FVector3f(PreViewTranslation + VertexFactory->GetQuadTreePositionWS()));
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Water.WaterMesh.LODMorphEnabled"));
const bool bLODMorphingEnabled = CVar && CVar->GetValueOnRenderThread() != 0;
ShaderBindings.Add(LODMorphingEnabledParameter, bLODMorphingEnabled ? 1 : 0);
}
else if (VertexStreams.Num() > 0)
{
for (int32 i = 0; i < WaterInstanceDataBuffersType::NumBuffers; ++i)
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshLODMorphEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:29
Scope: file
Source code excerpt:
/** Scalability CVars */
static TAutoConsoleVariable<int32> CVarWaterMeshLODMorphEnabled(
TEXT("r.Water.WaterMesh.LODMorphEnabled"), 1,
TEXT("If the smooth LOD morph is enabled. Turning this off may cause slight popping between LOD levels but will skip the calculations in the vertex shader, making it cheaper"),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeSuperSampling(
TEXT("r.Water.WaterMesh.GPUQuadTree.SuperSampling"), 2,
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:489
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
WaterQuadTreeGPUTraverseParams.DebugShowTile = CVarWaterMeshShowTileBounds.GetValueOnRenderThread();
WaterQuadTreeGPUTraverseParams.bWithWaterSelectionSupport = WITH_WATER_SELECTION_SUPPORT != 0;
WaterQuadTreeGPUTraverseParams.bLODMorphingEnabled = !!CVarWaterMeshLODMorphEnabled.GetValueOnRenderThread();
bNeedToTraverseGPUQuadTree = true;
}
using FWaterVertexFactoryUserDataWrapperType = TWaterVertexFactoryUserDataWrapper<WITH_WATER_SELECTION_SUPPORT>;
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:668
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
TraversalDesc.PreViewTranslation = View->ViewMatrices.GetPreViewTranslation();
TraversalDesc.LODScale = LODScale;
TraversalDesc.bLODMorphingEnabled = !!CVarWaterMeshLODMorphEnabled.GetValueOnRenderThread();
TraversalDesc.WaterInfoBounds = WaterInfoBounds;
TraversalDesc.OcclusionCullingResults = nullptr;
TraversalDesc.OcclusionCullingFarMeshOffset = OcclusionResultsFarMeshOffset;
if (CVarWaterMeshOcclusionCulling.GetValueOnRenderThread() != 0)
{
const FOcclusionCullingResults* CullingResults = OcclusionResults.Find(View->GetViewKey());
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:966
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicRayTracingInstances
Source code excerpt:
TraversalDesc.Frustum = FConvexVolume(); // Default volume to disable frustum culling
TraversalDesc.LODScale = LODScale;
TraversalDesc.bLODMorphingEnabled = !!CVarWaterMeshLODMorphEnabled.GetValueOnRenderThread();
TraversalDesc.WaterInfoBounds = WaterInfoBounds;
WaterQuadTree.BuildWaterTileInstanceData(TraversalDesc, WaterInstanceData);
if (WaterInstanceData.InstanceCount == 0)
{