r.Nanite.Culling.Frustum

r.Nanite.Culling.Frustum

#Overview

name: r.Nanite.Culling.Frustum

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.Nanite.Culling.Frustum is to control the frustum culling feature in Unreal Engine 5’s Nanite rendering system. This setting variable is used to enable or disable the culling of Nanite geometry that falls outside the view frustum.

The Nanite rendering system, which is part of Unreal Engine 5’s renderer module, relies on this setting variable. Specifically, it’s used in the Nanite culling and rasterization process.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of 1 (enabled). Developers can change this value at runtime using console commands or through code.

This variable interacts with the DebugFlags variable in the Nanite renderer. When r.Nanite.Culling.Frustum is set to 0, it sets the NANITE_DEBUG_FLAG_DISABLE_CULL_FRUSTUM flag in the DebugFlags.

Developers must be aware that disabling this culling feature (by setting it to 0) is primarily intended for testing and debugging purposes. Disabling frustum culling can significantly impact performance, as it would cause the engine to process geometry that isn’t visible to the camera.

Best practices when using this variable include:

  1. Keep it enabled (set to 1) for normal operation and final builds.
  2. Only disable it temporarily for debugging specific issues related to culling or visibility.
  3. Be cautious about performance implications when disabling this feature.

Regarding the associated variable CVarNaniteCullingFrustum, it is the actual console variable object that controls the r.Nanite.Culling.Frustum setting. It’s defined using the TAutoConsoleVariable template class, which allows it to be accessed and modified through the console variable system.

The purpose of CVarNaniteCullingFrustum is to provide a programmatic interface to control the Nanite frustum culling feature. It’s used internally by the Nanite renderer to check whether frustum culling should be applied.

This variable is part of the renderer module and is specifically used in the Nanite culling and rasterization process.

The value of CVarNaniteCullingFrustum is set when it’s defined, with a default value of 1. It can be changed at runtime using console commands or through C++ code using the console variable API.

CVarNaniteCullingFrustum interacts directly with the Nanite renderer’s debug flags. Its value is checked in the renderer initialization to determine whether to set the NANITE_DEBUG_FLAG_DISABLE_CULL_FRUSTUM flag.

Developers should be aware that this is a render thread safe variable, meaning it’s safe to read and write from the render thread. However, changes to this variable will only take effect on the render thread.

Best practices for using CVarNaniteCullingFrustum include:

  1. Use GetValueOnRenderThread() when accessing its value from the render thread.
  2. Consider performance implications when modifying this value, especially in shipping builds.
  3. Use this variable for debugging and testing purposes, but ensure it’s set to the default value (1) for normal operation and final builds.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:199

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarNaniteCullingFrustum(
	TEXT("r.Nanite.Culling.Frustum"),
	1,
	TEXT("Set to 0 to test disabling Nanite culling due to being outside of the view frustum."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarNaniteCullingGlobalClipPlane(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:198

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarNaniteCullingFrustum(
	TEXT("r.Nanite.Culling.Frustum"),
	1,
	TEXT("Set to 0 to test disabling Nanite culling due to being outside of the view frustum."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:2942

Scope (from outer to inner):

file
namespace    Nanite
function     FRenderer::FRenderer

Source code excerpt:

	// TODO: Exclude from shipping builds
	{
		if (CVarNaniteCullingFrustum.GetValueOnRenderThread() == 0)
		{
			DebugFlags |= NANITE_DEBUG_FLAG_DISABLE_CULL_FRUSTUM;
		}

		if (CVarNaniteCullingHZB.GetValueOnRenderThread() == 0)
		{