r.HeterogeneousVolumes.FrustumGrid.ShadingRate
r.HeterogeneousVolumes.FrustumGrid.ShadingRate
#Overview
name: r.HeterogeneousVolumes.FrustumGrid.ShadingRate
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The voxel tessellation rate, in pixel-space (Default = 4.0)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.HeterogeneousVolumes.FrustumGrid.ShadingRate is to control the voxel tessellation rate in pixel-space for heterogeneous volumes rendering in Unreal Engine 5. This setting is specifically related to the rendering system, particularly for volumetric effects.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the HeterogeneousVolumes subsystem. Based on the callsites, it’s clear that this variable is part of the volumetric rendering pipeline, which is responsible for rendering complex volumetric effects in the engine.
The value of this variable is set as a console variable with a default value of 4.0. It can be modified at runtime through the console or programmatically.
The associated variable CVarHeterogeneousVolumesFrustumGridShadingRate directly interacts with r.HeterogeneousVolumes.FrustumGrid.ShadingRate. This C++ variable is used to access and manipulate the console variable’s value within the engine’s code.
Developers must be aware that this variable affects the tessellation rate of voxels in the frustum grid used for heterogeneous volume rendering. A higher value will result in a finer tessellation, potentially improving visual quality at the cost of performance. Conversely, a lower value will reduce the tessellation rate, which may improve performance but could reduce visual fidelity.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your project, balancing visual quality and performance.
- Testing different values to find the optimal setting for your scene’s complexity and target hardware.
- Considering dynamic adjustment of this value based on scene conditions or performance metrics.
Regarding the associated variable CVarHeterogeneousVolumesFrustumGridShadingRate:
The purpose of CVarHeterogeneousVolumesFrustumGridShadingRate is to provide a programmatic interface to the r.HeterogeneousVolumes.FrustumGrid.ShadingRate console variable within the engine’s C++ code.
This variable is used in the Renderer module, specifically in the HeterogeneousVolumes namespace. It allows the engine to read and potentially modify the shading rate value during runtime.
The value of this variable is set when the console variable is initialized, and it reflects any changes made to the console variable.
CVarHeterogeneousVolumesFrustumGridShadingRate interacts directly with the r.HeterogeneousVolumes.FrustumGrid.ShadingRate console variable, serving as its C++ representation within the engine code.
Developers should be aware that this variable is used to access the console variable’s value on the render thread, as seen in the GetShadingRateForFrustumGrid() function.
Best practices for using this variable include:
- Always accessing it using the GetValueOnRenderThread() method when used in render thread contexts.
- Avoiding direct modification of this variable; instead, modify the console variable it represents.
- Considering caching the value if it’s accessed frequently, to avoid potential performance overhead from repeated console variable access.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesVoxelGridPipeline.cpp:24
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarHeterogeneousVolumesFrustumGridShadingRate(
TEXT("r.HeterogeneousVolumes.FrustumGrid.ShadingRate"),
4.0,
TEXT("The voxel tessellation rate, in pixel-space (Default = 4.0)"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarHeterogeneousVolumesFrustumGridNearPlaneDistance(
#Associated Variable and Callsites
This variable is associated with another variable named CVarHeterogeneousVolumesFrustumGridShadingRate
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesVoxelGridPipeline.cpp:23
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarHeterogeneousVolumesFrustumGridShadingRate(
TEXT("r.HeterogeneousVolumes.FrustumGrid.ShadingRate"),
4.0,
TEXT("The voxel tessellation rate, in pixel-space (Default = 4.0)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HeterogeneousVolumes/HeterogeneousVolumesVoxelGridPipeline.cpp:292
Scope (from outer to inner):
file
namespace HeterogeneousVolumes
function float GetShadingRateForFrustumGrid
Source code excerpt:
float GetShadingRateForFrustumGrid()
{
return FMath::Max(CVarHeterogeneousVolumesFrustumGridShadingRate.GetValueOnRenderThread(), 0.1);
}
float GetNearPlaneDistanceForFrustumGrid()
{
return CVarHeterogeneousVolumesFrustumGridNearPlaneDistance.GetValueOnRenderThread();
}