foliage.CullAllInVertexShader

foliage.CullAllInVertexShader

#Overview

name: foliage.CullAllInVertexShader

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 foliage.CullAllInVertexShader is to provide a debugging option for culling all instances of instanced static meshes in the vertex shader. This setting is primarily used in the context of foliage rendering and instanced static mesh optimization.

This setting variable is utilized by the Unreal Engine’s rendering system, specifically in the module responsible for handling instanced static meshes. It’s part of the Engine’s core rendering functionality, as evidenced by its location in the Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning the feature is disabled by default. Developers can change this value at runtime using console commands or through configuration files.

The associated variable CVarCullAllInVertexShader is directly linked to foliage.CullAllInVertexShader. They share the same value and purpose, with CVarCullAllInVertexShader being the C++ representation of the console variable.

Developers must be aware that this variable is intended for debugging purposes only. When enabled (set to a value greater than 0), it forces all instances to be culled in the vertex shader, which can significantly impact rendering performance and visual output. It’s not meant for use in production builds or normal gameplay scenarios.

Best practices when using this variable include:

  1. Only enable it temporarily for debugging specific issues related to instanced mesh culling.
  2. Remember to disable it (set to 0) after debugging to restore normal rendering behavior.
  3. Use it in conjunction with other debugging tools and profilers to identify potential issues in instance culling or rendering.
  4. Be cautious when using it in large scenes with many instanced meshes, as it may cause significant performance overhead.

Regarding the associated variable CVarCullAllInVertexShader:

In summary, both foliage.CullAllInVertexShader and CVarCullAllInVertexShader provide a powerful debugging tool for instanced mesh rendering, but should be used cautiously and only when investigating specific culling or rendering issues related to instanced static meshes.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:101

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarCullAllInVertexShader(
	TEXT("foliage.CullAllInVertexShader"),
	0,
	TEXT("Debugging, if this is greater than 0, cull all instances in the vertex shader."));

static TAutoConsoleVariable<int32> CVarRayTracingRenderInstances(
	TEXT("r.RayTracing.Geometry.InstancedStaticMeshes"),
	1,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:100

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_Default);

static TAutoConsoleVariable<int32> CVarCullAllInVertexShader(
	TEXT("foliage.CullAllInVertexShader"),
	0,
	TEXT("Debugging, if this is greater than 0, cull all instances in the vertex shader."));

static TAutoConsoleVariable<int32> CVarRayTracingRenderInstances(
	TEXT("r.RayTracing.Geometry.InstancedStaticMeshes"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:1267

Scope (from outer to inner):

file
function     FInstancedStaticMeshVFLooseUniformShaderParametersRef FInstancedStaticMeshSceneProxy::CreateLooseUniformBuffer

Source code excerpt:

				InstancingFadeOutParams.Y = 0.f;
			}
			if (CVarCullAllInVertexShader.GetValueOnRenderThread() > 0)
			{
				InstancingFadeOutParams.Z = 0.0f;
				InstancingFadeOutParams.W = 0.0f;
			}
			else
			{