r.VoxelMethod
r.VoxelMethod
#Overview
name: r.VoxelMethod
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VoxelMethod is to control the voxel rendering method in Unreal Engine’s Nanite system, which is part of the rendering subsystem. This setting variable allows developers to choose between different voxel rendering techniques.
The Unreal Engine subsystem that relies on this setting variable is the Nanite rendering system, specifically within the voxel rendering component. This can be inferred from the file location (Nanite/Voxel.cpp) and the namespace (Nanite) where the variable is used.
The value of this variable is set using the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with an initial value of 0, which suggests that it can be changed at runtime through console commands or configuration files.
The associated variable CVarVoxelMethod directly interacts with r.VoxelMethod. They share the same value, and CVarVoxelMethod is used to access the value of r.VoxelMethod within the C++ code.
Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread. The variable is an int32, suggesting that it might support multiple voxel rendering methods, with 0 being the default.
Best practices when using this variable include:
- Understanding the different voxel methods available and their impact on performance and visual quality.
- Testing different values to find the optimal setting for your specific use case.
- Considering the performance implications of changing this value, especially in real-time applications.
Regarding the associated variable CVarVoxelMethod:
The purpose of CVarVoxelMethod is to provide a programmatic interface to access and manipulate the r.VoxelMethod setting within the C++ code of the Nanite rendering system.
It is used directly in the DrawVisibleBricks function of the Nanite namespace to determine which voxel rendering method to use. The value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access on the render thread.
Developers should be aware that changes to CVarVoxelMethod will directly affect the behavior of the voxel rendering system. The switch statement suggests that different voxel methods are implemented for different values of this variable.
Best practices for using CVarVoxelMethod include:
- Always accessing the value using GetValueOnRenderThread() when in render thread code.
- Considering caching the value if it’s accessed frequently in performance-critical sections.
- Documenting the effects of different values for maintainability and ease of use by other team members.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/Voxel.cpp:19
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVoxelMethod(
TEXT("r.VoxelMethod"),
0,
TEXT(""),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarVoxelLevel2(
#Associated Variable and Callsites
This variable is associated with another variable named CVarVoxelMethod
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/Voxel.cpp:18
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarVoxelMethod(
TEXT("r.VoxelMethod"),
0,
TEXT(""),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/Voxel.cpp:301
Scope (from outer to inner):
file
namespace Nanite
function void DrawVisibleBricks
Source code excerpt:
}
int32 VoxelMethod = CVarVoxelMethod.GetValueOnRenderThread();
switch( VoxelMethod )
{
default:
case 0: // Rasterize bricks
{