r.Water.WaterMesh.OcclusionCulling
r.Water.WaterMesh.OcclusionCulling
#Overview
name: r.Water.WaterMesh.OcclusionCulling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables occlusion culling for the CPU water quadtree.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.OcclusionCulling is to enable occlusion culling for the CPU water quadtree in Unreal Engine 5’s water rendering system. This setting variable is part of the experimental Water plugin and is used to optimize the rendering of water surfaces.
This setting variable is primarily used in the Water plugin, specifically in the WaterMeshSceneProxy component. It’s part of the rendering system, focusing on water rendering optimization.
The value of this variable is set using a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default. Developers can change this value at runtime or in configuration files.
The associated variable CVarWaterMeshOcclusionCulling directly interacts with r.Water.WaterMesh.OcclusionCulling. They share the same value and purpose.
Developers must be aware that enabling this variable (setting it to a non-zero value) will activate occlusion culling for the CPU water quadtree. This can potentially improve performance by reducing the rendering of water surfaces that are not visible to the camera.
Best practices when using this variable include:
- Testing the performance impact in various scenarios, as occlusion culling may not always be beneficial depending on the scene complexity and water visibility.
- Considering the trade-off between potential performance gains and any visual artifacts that might occur due to occlusion culling.
- Using it in conjunction with other water rendering optimizations for best results.
- Monitoring its impact on different hardware configurations, as the benefits may vary.
Regarding the associated variable CVarWaterMeshOcclusionCulling:
- Its purpose is identical to r.Water.WaterMesh.OcclusionCulling.
- It’s used within the Water plugin’s rendering system.
- Its value is set through the same CVar system.
- It directly controls whether occlusion culling is applied to the water mesh.
- Developers should treat it as they would r.Water.WaterMesh.OcclusionCulling, as they are essentially the same variable.
The best practices and considerations mentioned for r.Water.WaterMesh.OcclusionCulling apply equally to CVarWaterMeshOcclusionCulling.
#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:141
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCulling(
TEXT("r.Water.WaterMesh.OcclusionCulling"),
0,
TEXT("Enables occlusion culling for the CPU water quadtree."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarWaterMeshOcclusionCullExpandBoundsAmountXY(
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshOcclusionCulling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:140
Scope: file
Source code excerpt:
#endif
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCulling(
TEXT("r.Water.WaterMesh.OcclusionCulling"),
0,
TEXT("Enables occlusion culling for the CPU water quadtree."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:672
Scope (from outer to inner):
file
function void FWaterMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
TraversalDesc.OcclusionCullingResults = nullptr;
TraversalDesc.OcclusionCullingFarMeshOffset = OcclusionResultsFarMeshOffset;
if (CVarWaterMeshOcclusionCulling.GetValueOnRenderThread() != 0)
{
const FOcclusionCullingResults* CullingResults = OcclusionResults.Find(View->GetViewKey());
if (CullingResults && !CullingResults->Results.IsEmpty())
{
TraversalDesc.OcclusionCullingResults = &CullingResults->Results;
}
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:844
Scope (from outer to inner):
file
function const TArray<FBoxSphereBounds>* FWaterMeshSceneProxy::GetOcclusionQueries
Source code excerpt:
const TArray<FBoxSphereBounds>* FWaterMeshSceneProxy::GetOcclusionQueries(const FSceneView* View) const
{
if (CVarWaterMeshOcclusionCulling.GetValueOnRenderThread() != 0)
{
return &OcclusionCullingBounds;
}
return &EmptyOcclusionCullingBounds;
}