r.LumenScene.Heightfield.CullForView

r.LumenScene.Heightfield.CullForView

#Overview

name: r.LumenScene.Heightfield.CullForView

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LumenScene.Heightfield.CullForView is to enable or disable heightfield culling in the Lumen scene rendering system. This setting variable is part of Unreal Engine 5’s Lumen global illumination system, specifically for optimizing the rendering of heightfields.

This setting variable is primarily used in the Renderer module, particularly in the Lumen subsystem. Based on the callsites, it’s implemented in the LumenMeshSDFCulling.cpp file, which suggests it’s related to culling operations for mesh signed distance fields (SDFs) and heightfields in the Lumen rendering pipeline.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning heightfield culling is enabled by default. Developers can change this value at runtime using console commands or through project settings.

The associated variable CVarLumenSceneHeightfieldCullForView directly interacts with r.LumenScene.Heightfield.CullForView. They share the same value and purpose.

Developers should be aware that this variable affects rendering performance and visual quality. Enabling culling (value = 1) can improve performance by reducing the number of heightfields processed, but it might affect visual quality in some scenarios.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) for optimal performance in most cases.
  2. If you notice visual artifacts or missing details in your scene’s global illumination, particularly related to terrain or large-scale environment features, you might want to disable it (set to 0) for debugging purposes.
  3. Profile your game with both settings to understand the performance impact in your specific use case.
  4. Consider exposing this setting in your game’s graphics options for users with high-end hardware who might prefer visual quality over performance.

Regarding the associated variable CVarLumenSceneHeightfieldCullForView:

The purpose of CVarLumenSceneHeightfieldCullForView is identical to r.LumenScene.Heightfield.CullForView. It’s the actual console variable implementation that controls the heightfield culling behavior.

This variable is used in the Renderer module, specifically in the Lumen subsystem’s culling operations. It’s defined and used in the LumenMeshSDFCulling.cpp file.

The value of CVarLumenSceneHeightfieldCullForView is set when the engine initializes the console variables. It can be modified at runtime through console commands.

This variable directly controls the behavior of the heightfield culling process. In the provided code snippet, we can see it’s used in the CullHeightfieldObjectsForView function to determine whether culling should be performed.

Developers should be aware that changes to this variable will immediately affect the rendering pipeline. It’s thread-safe for the render thread, as indicated by the ECVF_RenderThreadSafe flag.

Best practices for using CVarLumenSceneHeightfieldCullForView are the same as for r.LumenScene.Heightfield.CullForView, as they represent the same setting. Developers should use this variable name when accessing the setting programmatically in C++ code.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:56

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLumenSceneHeightfieldCullForView(
	TEXT("r.LumenScene.Heightfield.CullForView"),
	1,
	TEXT("Enables Heightfield culling (default = 1)"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenSceneHeightfieldFroxelCulling(

#Associated Variable and Callsites

This variable is associated with another variable named CVarLumenSceneHeightfieldCullForView. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:55

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarLumenSceneHeightfieldCullForView(
	TEXT("r.LumenScene.Heightfield.CullForView"),
	1,
	TEXT("Enables Heightfield culling (default = 1)"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenMeshSDFCulling.cpp:553

Scope (from outer to inner):

file
function     void CullHeightfieldObjectsForView

Source code excerpt:

		PassParameters->MaxMeshSDFInfluenceRadius = MaxMeshSDFInfluenceRadius;
		PassParameters->MaxNumObjects = NumHeightfields;
		PassParameters->bShouldCull = CVarLumenSceneHeightfieldCullForView.GetValueOnRenderThread() != 0;
		PassParameters->ObjectBoundingGeometryIndexCount = StencilingGeometry::GLowPolyStencilSphereIndexBuffer.GetIndexCount();

		PassParameters->RWNumCulledObjects = GraphBuilder.CreateUAV(NumHeightfieldCulledObjects, PF_R32_UINT);
		PassParameters->RWCulledObjectIndexBuffer = GraphBuilder.CreateUAV(HeightfieldObjectIndexBuffer, PF_R32_UINT);
		PassParameters->RWObjectIndirectArguments = GraphBuilder.CreateUAV(HeightfieldObjectIndirectArguments, PF_R32_UINT);
	}