r.Water.WaterMesh.OcclusionCulling

r.Water.WaterMesh.OcclusionCulling

#Overview

name: r.Water.WaterMesh.OcclusionCulling

This variable is created as a Console Variable (cvar).

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:

  1. Testing the performance impact in various scenarios, as occlusion culling may not always be beneficial depending on the scene complexity and water visibility.
  2. Considering the trade-off between potential performance gains and any visual artifacts that might occur due to occlusion culling.
  3. Using it in conjunction with other water rendering optimizations for best results.
  4. Monitoring its impact on different hardware configurations, as the benefits may vary.

Regarding the associated variable CVarWaterMeshOcclusionCulling:

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;
}