r.RayTracing.Geometry.NaniteProxies

r.RayTracing.Geometry.NaniteProxies

#Overview

name: r.RayTracing.Geometry.NaniteProxies

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.Geometry.NaniteProxies is to control the inclusion of Nanite proxy meshes in ray tracing effects within Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for ray tracing functionality.

The Unreal Engine subsystems that rely on this setting variable are the rendering system and the Nanite geometry system. It is mainly used in the Engine and Renderer modules.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1, which means Nanite proxy meshes are enabled in ray tracing by default.

This variable interacts with other ray tracing-related variables, such as r.RayTracing.Geometry.StaticMeshes, r.RayTracing.Geometry.HierarchicalInstancedStaticMesh, and r.RayTracing.Geometry.LandscapeGrass. These variables collectively control which geometry types are included in ray tracing.

Developers must be aware that changing this variable will affect the inclusion of Nanite proxy meshes in ray tracing effects. Setting it to 0 will exclude Nanite proxy meshes from ray tracing, potentially improving performance but at the cost of visual quality or accuracy.

Best practices when using this variable include:

  1. Keep it enabled (value 1) for the most accurate ray tracing results.
  2. Consider disabling it (value 0) if performance is a significant concern and the visual impact is acceptable.
  3. Test the impact of enabling/disabling this feature in various scenarios to find the right balance between performance and visual quality.

Regarding the associated variable CVarRayTracingNaniteProxyMeshes:

The purpose of CVarRayTracingNaniteProxyMeshes is to provide a programmatic interface to the r.RayTracing.Geometry.NaniteProxies setting. It is used internally by the engine to access and modify the setting value.

This variable is part of the engine’s console variable system and is used in the Nanite and ray tracing subsystems.

The value of this variable is set when the engine initializes the console variable system, and it can be changed at runtime through console commands or programmatically.

CVarRayTracingNaniteProxyMeshes directly controls the behavior defined by r.RayTracing.Geometry.NaniteProxies. They share the same value and purpose.

Developers should be aware that this variable is used in performance-critical rendering code, so frequent changes to its value during runtime may have performance implications.

Best practices for using CVarRayTracingNaniteProxyMeshes include:

  1. Use it for runtime modifications of the Nanite proxy mesh ray tracing behavior.
  2. Cache its value when appropriate to avoid frequent calls to GetValueOnRenderThread().
  3. Consider the performance implications of changing this value frequently during rendering.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:106

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingNaniteProxyMeshes(
	TEXT("r.RayTracing.Geometry.NaniteProxies"),
	1,
	TEXT("Include Nanite proxy meshes in ray tracing effects (default = 1 (Nanite proxy meshes enabled in ray tracing))"));

static int32 GNaniteRayTracingMode = 0;
static FAutoConsoleVariableRef CVarNaniteRayTracingMode(
	TEXT("r.RayTracing.Nanite.Mode"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracing.cpp:106

Scope (from outer to inner):

file
function     static void RefreshRayTracingInstancesSinkFunction

Source code excerpt:

	static const auto RayTracingStaticMeshesCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RayTracing.Geometry.StaticMeshes"));
	static const auto RayTracingHISMCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RayTracing.Geometry.HierarchicalInstancedStaticMesh"));
	static const auto RayTracingNaniteProxiesCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RayTracing.Geometry.NaniteProxies"));
	static const auto RayTracingLandscapeGrassCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RayTracing.Geometry.LandscapeGrass"));

	static int32 CachedRayTracingStaticMeshes = RayTracingStaticMeshesCVar->GetValueOnGameThread();
	static int32 CachedRayTracingHISM = RayTracingHISMCVar->GetValueOnGameThread();
	static int32 CachedRayTracingNaniteProxies = RayTracingNaniteProxiesCVar->GetValueOnGameThread();
	static int32 CachedRayTracingLandscapeGrass = RayTracingLandscapeGrassCVar->GetValueOnGameThread();

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:105

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarRayTracingNaniteProxyMeshes(
	TEXT("r.RayTracing.Geometry.NaniteProxies"),
	1,
	TEXT("Include Nanite proxy meshes in ray tracing effects (default = 1 (Nanite proxy meshes enabled in ray tracing))"));

static int32 GNaniteRayTracingMode = 0;
static FAutoConsoleVariableRef CVarNaniteRayTracingMode(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:1833

Scope (from outer to inner):

file
namespace    Nanite
function     void FSceneProxy::GetDynamicRayTracingInstances

Source code excerpt:

	check(!IsRayTracingStaticRelevant());

	if (CVarRayTracingNaniteProxyMeshes.GetValueOnRenderThread() == 0 || !bHasRayTracingInstances)
	{
		return;
	}

	if (GetRayTracingMode() != ERayTracingMode::Fallback)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Rendering/NaniteResources.cpp:1918

Scope (from outer to inner):

file
namespace    Nanite
function     ERayTracingPrimitiveFlags FSceneProxy::GetCachedRayTracingInstance

Source code excerpt:

	}

	if (CVarRayTracingNaniteProxyMeshes.GetValueOnRenderThread() == 0 || !bHasRayTracingInstances)
	{
		return ERayTracingPrimitiveFlags::Exclude;
	}

	static const auto RayTracingStaticMeshesCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RayTracing.Geometry.StaticMeshes"));