r.RayTracing.Geometry.InstancedStaticMeshes
r.RayTracing.Geometry.InstancedStaticMeshes
#Overview
name: r.RayTracing.Geometry.InstancedStaticMeshes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Include static mesh instances in ray tracing effects (default = 1 (Instances enabled in ray tracing))
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Geometry.InstancedStaticMeshes is to control the inclusion of static mesh instances in ray tracing effects within Unreal Engine 5.
This setting variable is primarily used by the rendering system, specifically for ray tracing functionality. It is part of the Engine module, as evident from its location in the InstancedStaticMesh.cpp file within the Engine source directory.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1, which means instances are enabled in ray tracing by default.
The associated variable CVarRayTracingRenderInstances directly interacts with r.RayTracing.Geometry.InstancedStaticMeshes. They share the same value and purpose.
Developers must be aware that this variable affects the performance and visual quality of ray tracing effects. Enabling it (value = 1) includes static mesh instances in ray tracing, potentially increasing visual fidelity but also increasing computational cost. Disabling it (value = 0) excludes these instances, which might improve performance at the cost of visual accuracy.
Best practices when using this variable include:
- Consider the performance impact when enabling it for complex scenes with many instanced static meshes.
- Use it in conjunction with other ray tracing settings for optimal results.
- Test the visual and performance differences with it enabled and disabled to find the right balance for your project.
Regarding the associated variable CVarRayTracingRenderInstances:
- It serves the same purpose as r.RayTracing.Geometry.InstancedStaticMeshes.
- It is used in the GetDynamicRayTracingInstances function of the FInstancedStaticMeshSceneProxy class to determine whether to proceed with ray tracing for instanced static meshes.
- Developers should be aware that changing the value of this variable at runtime will affect the ray tracing behavior for instanced static meshes.
- Best practices include using this variable for runtime toggling of instanced static mesh ray tracing, which can be useful for performance optimization or debugging purposes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:106
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingRenderInstances(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes"),
1,
TEXT("Include static mesh instances in ray tracing effects (default = 1 (Instances enabled in ray tracing))"));
static TAutoConsoleVariable<int32> CVarRayTracingInstancedStaticMeshesMinLOD(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.MinLOD"),
0,
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingRenderInstances
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:105
Scope: file
Source code excerpt:
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,
TEXT("Include static mesh instances in ray tracing effects (default = 1 (Instances enabled in ray tracing))"));
static TAutoConsoleVariable<int32> CVarRayTracingInstancedStaticMeshesMinLOD(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.MinLOD"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:1608
Scope (from outer to inner):
file
function void FInstancedStaticMeshSceneProxy::GetDynamicRayTracingInstances
Source code excerpt:
void FInstancedStaticMeshSceneProxy::GetDynamicRayTracingInstances(struct FRayTracingMaterialGatheringContext& Context, TArray<FRayTracingInstance>& OutRayTracingInstances)
{
if (!CVarRayTracingRenderInstances.GetValueOnRenderThread())
{
return;
}
if (!bSupportRayTracing)
{