r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh
r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh
#Overview
name: r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When occlusion culling is enabled, always do occlusion queries for the water far mesh, independent of r.Water.WaterMesh.OcclusionCulling.MaxQueries.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh is to control the occlusion culling behavior for water far meshes in Unreal Engine 5’s water rendering system.
This setting variable is part of the Water plugin, specifically within the rendering subsystem for water meshes. It is used in the WaterMeshSceneProxy.cpp file, which is responsible for handling the scene proxy for water meshes.
The value of this variable is set through a console variable (CVar) system in Unreal Engine. It is initialized with a default value of 1 (enabled) and can be changed at runtime.
The associated variable CVarWaterMeshOcclusionCullingIncludeFarMesh directly interacts with r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh. They share the same value and purpose.
Developers must be aware that this variable affects the performance and visual quality of water rendering, especially for distant water meshes. When enabled (set to 1), it forces occlusion queries for the water far mesh, regardless of the maximum number of queries set by another variable (r.Water.WaterMesh.OcclusionCulling.MaxQueries).
Best practices when using this variable include:
- Enabling it (set to 1) for higher visual quality, especially in scenes with large water bodies.
- Disabling it (set to 0) if performance is a concern and distant water meshes are not critical to the scene.
- Testing the impact on performance and visual quality in various scenarios to find the optimal setting for your specific game or application.
Regarding the associated variable CVarWaterMeshOcclusionCullingIncludeFarMesh:
The purpose of CVarWaterMeshOcclusionCullingIncludeFarMesh is identical to r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh, as they share the same value and functionality.
This variable is used within the Water plugin’s runtime module, specifically in the WaterMeshSceneProxy class.
The value is set and accessed using the Unreal Engine’s CVar system, allowing for runtime configuration.
It interacts directly with r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh and is used in conjunction with other water rendering CVars like CVarWaterMeshOcclusionCullingMaxQueries.
Developers should be aware that this variable is used in the construction of the WaterMeshSceneProxy and affects the computation of occlusion culling bounds.
Best practices for using this variable are the same as those for r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh, as they are essentially the same setting represented in two different ways within the engine.
#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:80
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCullingIncludeFarMesh(
TEXT("r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh"), 1,
TEXT("When occlusion culling is enabled, always do occlusion queries for the water far mesh, independent of r.Water.WaterMesh.OcclusionCulling.MaxQueries."),
ECVF_Scalability);
/** Debug CVars */
static TAutoConsoleVariable<int32> CVarWaterMeshShowWireframe(
TEXT("r.Water.WaterMesh.ShowWireframe"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshOcclusionCullingIncludeFarMesh
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:79
Scope: file
Source code excerpt:
ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarWaterMeshOcclusionCullingIncludeFarMesh(
TEXT("r.Water.WaterMesh.OcclusionCulling.IncludeFarMesh"), 1,
TEXT("When occlusion culling is enabled, always do occlusion queries for the water far mesh, independent of r.Water.WaterMesh.OcclusionCulling.MaxQueries."),
ECVF_Scalability);
/** Debug CVars */
static TAutoConsoleVariable<int32> CVarWaterMeshShowWireframe(
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:265
Scope (from outer to inner):
file
function FWaterMeshSceneProxy::FWaterMeshSceneProxy
Source code excerpt:
// Always do CPU occlusion queries, even if this is a GPU quadtree. The GPU quadtree still potentially uses the far mesh which is CPU driven.
const int32 MaxQueries = CVarWaterMeshOcclusionCullingMaxQueries.GetValueOnGameThread();
const bool bIncludeFarMeshOcclusionQueries = CVarWaterMeshOcclusionCullingIncludeFarMesh.GetValueOnGameThread() != 0;
OcclusionCullingBounds = WaterQuadTree.ComputeNodeBounds(MaxQueries, CVarWaterMeshOcclusionCullExpandBoundsAmountXY.GetValueOnGameThread(), bIncludeFarMeshOcclusionQueries, &OcclusionResultsFarMeshOffset);
EmptyOcclusionCullingBounds.Add(WaterQuadTree.GetBoundsIncludingFarMesh());
// If this is a GPU quadtree, the CPU root node will have an invalid bounding box, so derive conservative bounds now
if (bIsGPUQuadTree && !OcclusionCullingBounds.IsEmpty())
{
OcclusionCullingBounds[0] = FBox(FVector(WaterQuadTree.GetTileRegion().Min, WaterQuadTreeMinHeight), FVector(WaterQuadTree.GetTileRegion().Max, WaterQuadTreeMaxHeight));