r.RayTracing.DecalGrid.MaxCount
r.RayTracing.DecalGrid.MaxCount
#Overview
name: r.RayTracing.DecalGrid.MaxCount
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the maximum number of decals per cell in the 2D decal grid. The minimum of this value and the number of decal in the scene is used. (default = 128)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.DecalGrid.MaxCount is to control the maximum number of decals per cell in the 2D decal grid used in ray tracing. This setting is part of the rendering system, specifically for ray-traced decals.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the ray tracing subsystem for decals. It’s referenced in the RayTracingDecals.cpp file, which is responsible for handling ray-traced decals.
The value of this variable is set as a console variable (CVar) with a default value of 128. It can be modified at runtime through the console or configuration files.
The associated variable CVarDecalGridMaxCount interacts directly with r.RayTracing.DecalGrid.MaxCount. They share the same value and purpose.
Developers must be aware that:
- This variable affects performance and visual quality of ray-traced decals.
- The actual number of decals per cell is the minimum between this value and the total number of decals in the scene.
- The value is clamped between 1 and the constant RAY_TRACING_DECAL_COUNT_MAXIMUM.
Best practices when using this variable include:
- Adjust the value based on the scene’s decal complexity and performance requirements.
- Monitor performance impacts when increasing this value, as it may affect memory usage and rendering time.
- Use in conjunction with other decal-related settings for optimal results.
Regarding the associated variable CVarDecalGridMaxCount:
- It’s the C++ variable that directly controls the console variable r.RayTracing.DecalGrid.MaxCount.
- It’s used in the BuildDecalGrid function to determine the maximum number of decals per grid cell.
- The value is retrieved using GetValueOnRenderThread(), ensuring thread-safe access.
- It’s clamped to ensure it’s within valid ranges before being used in calculations.
Developers should use CVarDecalGridMaxCount.GetValueOnRenderThread() when accessing this value in C++ code to ensure thread-safe operations in the rendering pipeline.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp:21
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDecalGridMaxCount(
TEXT("r.RayTracing.DecalGrid.MaxCount"),
128,
TEXT("Controls the maximum number of decals per cell in the 2D decal grid. The minimum of this value and the number of decal in the scene is used. (default = 128)\n"),
ECVF_RenderThreadSafe
);
enum class EDecalsWriteFlags : uint32
#Associated Variable and Callsites
This variable is associated with another variable named CVarDecalGridMaxCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp:20
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarDecalGridMaxCount(
TEXT("r.RayTracing.DecalGrid.MaxCount"),
128,
TEXT("Controls the maximum number of decals per cell in the 2D decal grid. The minimum of this value and the number of decal in the scene is used. (default = 128)\n"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp:392
Scope (from outer to inner):
file
function void BuildDecalGrid
Source code excerpt:
{
const uint32 Resolution = FMath::RoundUpToPowerOfTwo(CVarDecalGridResolution.GetValueOnRenderThread());
const uint32 MaxCount = FMath::Clamp(CVarDecalGridMaxCount.GetValueOnRenderThread(), 1, FMath::Min((int32)NumDecals, RAY_TRACING_DECAL_COUNT_MAXIMUM));
OutParameters.GridResolution = Resolution;
OutParameters.GridMaxCount = MaxCount;
// pick the shortest axis
FVector3f Diag = OutParameters.TranslatedBoundMax - OutParameters.TranslatedBoundMin;
if (Diag.X < Diag.Y && Diag.X < Diag.Z)