r.RayTracing.DecalGrid.Resolution
r.RayTracing.DecalGrid.Resolution
#Overview
name: r.RayTracing.DecalGrid.Resolution
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the resolution of the 2D decal grid used to cull irrelevant decal from calculations (default = 256)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.DecalGrid.Resolution is to control the resolution of the 2D decal grid used for culling irrelevant decals in ray tracing calculations. This setting variable is primarily used in the rendering system, specifically for ray tracing decals.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the ray tracing component for decals. This can be seen from the file location: Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp.
The value of this variable is set as a console variable with a default value of 256. It can be modified at runtime through console commands or programmatically.
This variable interacts with another variable named CVarDecalGridMaxCount, which is used in conjunction to determine the parameters for the decal grid.
Developers must be aware that this variable affects the performance and quality of ray-traced decals. A higher resolution may provide more accurate culling but at the cost of increased memory usage and potentially lower performance.
Best practices when using this variable include:
- Adjusting the value based on the scene complexity and the number of decals.
- Balancing between performance and visual quality.
- Testing different values to find the optimal setting for specific scenes.
Regarding the associated variable CVarDecalGridResolution:
The purpose of CVarDecalGridResolution is the same as r.RayTracing.DecalGrid.Resolution, as they share the same value. It’s an internal representation of the console variable within the C++ code.
This variable is used directly in the BuildDecalGrid function to determine the grid resolution. The value is rounded up to the nearest power of two, which developers should keep in mind when setting the console variable.
When using CVarDecalGridResolution, developers should be aware that it’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access to the variable’s value.
Best practices for CVarDecalGridResolution include:
- Accessing it only on the render thread to avoid potential race conditions.
- Considering the power-of-two rounding when setting values.
- Using it in conjunction with CVarDecalGridMaxCount to fully define the decal grid parameters.
#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:14
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDecalGridResolution(
TEXT("r.RayTracing.DecalGrid.Resolution"),
256,
TEXT("Controls the resolution of the 2D decal grid used to cull irrelevant decal from calculations (default = 256)\n"),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<int32> CVarDecalGridMaxCount(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDecalGridResolution
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp:13
Scope: file
Source code excerpt:
#include <limits>
TAutoConsoleVariable<int32> CVarDecalGridResolution(
TEXT("r.RayTracing.DecalGrid.Resolution"),
256,
TEXT("Controls the resolution of the 2D decal grid used to cull irrelevant decal from calculations (default = 256)\n"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDecals.cpp:391
Scope (from outer to inner):
file
function void BuildDecalGrid
Source code excerpt:
if (NumDecals > 0)
{
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;