r.HairStrands.Shadow.CullPerObjectShadowCaster

r.HairStrands.Shadow.CullPerObjectShadowCaster

#Overview

name: r.HairStrands.Shadow.CullPerObjectShadowCaster

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.HairStrands.Shadow.CullPerObjectShadowCaster is to enable CPU culling of objects casting per-object shadows, specifically for stationary objects in the context of hair strand rendering.

This setting variable is primarily used in the rendering system, specifically for shadow rendering and hair strand rendering. It is part of the Unreal Engine’s renderer module, as evidenced by its location in the ShadowRendering.cpp file.

The value of this variable is set through a console variable (CVarHairStrandsCullPerObjectShadowCaster) with a default value of 1, meaning it’s enabled by default. It can be changed at runtime through console commands or programmatically.

The associated variable CVarHairStrandsCullPerObjectShadowCaster directly interacts with it, as they share the same value and purpose.

Developers must be aware that this variable affects performance and visual quality. When enabled, it can improve performance by reducing the number of objects that need to be processed for shadow casting, but it may also potentially cause visual artifacts if the culling is too aggressive.

Best practices when using this variable include:

  1. Testing the impact on performance and visual quality in your specific use case.
  2. Considering disabling it if you notice missing shadows from hair strands.
  3. Balancing between performance gains and visual quality based on your project’s requirements.

Regarding the associated variable CVarHairStrandsCullPerObjectShadowCaster:

Its purpose is identical to r.HairStrands.Shadow.CullPerObjectShadowCaster, serving as the actual console variable implementation.

It is used in the renderer module, specifically in shadow rendering calculations for hair strands.

The value is set when the console variable is initialized and can be changed at runtime.

It directly controls the behavior of the culling system for per-object shadow casters in hair strand rendering.

Developers should be aware that changing this variable’s value will immediately affect the shadow rendering behavior for hair strands.

Best practices include using this variable for debugging or fine-tuning performance, and considering exposing it as a configurable option in graphics settings if shadow quality for hair is a critical aspect of your game.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:237

Scope: file

Source code excerpt:

// Hair
static TAutoConsoleVariable<int32> CVarHairStrandsCullPerObjectShadowCaster(
	TEXT("r.HairStrands.Shadow.CullPerObjectShadowCaster"),
	1,
	TEXT("Enable CPU culling of object casting per-object shadow (stationnary object)"),
	ECVF_RenderThreadSafe);

DEFINE_GPU_STAT(ShadowProjection);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:236

Scope: file

Source code excerpt:

///////////////////////////////////////////////////////////////////////////////////////////////////
// Hair
static TAutoConsoleVariable<int32> CVarHairStrandsCullPerObjectShadowCaster(
	TEXT("r.HairStrands.Shadow.CullPerObjectShadowCaster"),
	1,
	TEXT("Enable CPU culling of object casting per-object shadow (stationnary object)"),
	ECVF_RenderThreadSafe);

DEFINE_GPU_STAT(ShadowProjection);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1174

Scope: file

Source code excerpt:


		const bool bValidPlanes = FrustumVertices.Num() > 0;
		if (bValidPlanes && CVarHairStrandsCullPerObjectShadowCaster.GetValueOnRenderThread() > 0)
		{
			// Skip volume which does not intersect hair clusters
			bool bIntersect = bValidPlanes;
			for (const FHairStrandsMacroGroupData& Data : View->HairStrandsViewData.MacroGroupDatas)
			{
				const FSphere BoundSphere = Data.Bounds.GetSphere();

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowRendering.cpp:1590

Scope (from outer to inner):

file
function     void FProjectedShadowInfo::RenderOnePassPointLightProjection
lambda-function

Source code excerpt:

			// Skip volume which does not intersect hair clusters
			bool bIntersect = false;
			if (CVarHairStrandsCullPerObjectShadowCaster.GetValueOnRenderThread() > 0)
			{
				for (const FHairStrandsMacroGroupData& Data : View.HairStrandsViewData.MacroGroupDatas)
				{
					const FSphere BoundSphere = Data.Bounds.GetSphere();
					if (BoundSphere.Intersects(LightBounds))
					{