r.ApproximateOcclusionQueries
r.ApproximateOcclusionQueries
#Overview
name: r.ApproximateOcclusionQueries
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Batch occlusion for a static and skeletal mesh even if there are movable.In general it\'s more beneficial to batch occlusion queires for all meshes
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ApproximateOcclusionQueries is to control the batching of occlusion queries for static and skeletal meshes in the rendering system. It is specifically designed to optimize the occlusion query process, which is crucial for determining object visibility and improving rendering performance.
This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically within the PrimitiveSceneProxy component. It’s part of the engine’s core rendering module, as evidenced by its location in the Engine/Source/Runtime/Engine directory.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning the feature is disabled by default. Developers or users can change this value at runtime using console commands or through configuration files.
The associated variable CVarApproximateOcclusionQueries directly interacts with r.ApproximateOcclusionQueries. They share the same value and purpose, with CVarApproximateOcclusionQueries being the actual C++ variable used in the code to access and control this setting.
Developers must be aware that enabling this feature (setting the value to non-zero) will cause the engine to batch occlusion queries for static and skeletal meshes, even if they are movable. This can have performance implications and may affect the accuracy of visibility determinations in some scenarios.
Best practices when using this variable include:
- Testing thoroughly to ensure that enabling this feature doesn’t introduce visual artifacts or incorrect occlusion in your specific use case.
- Benchmarking performance with this feature both enabled and disabled to determine if it provides a meaningful benefit for your project.
- Consider enabling this feature in scenarios where you have many static and skeletal meshes, as batching occlusion queries can potentially improve performance.
- Be cautious when using this feature with frequently moving objects, as it may lead to less accurate occlusion results.
Regarding the associated variable CVarApproximateOcclusionQueries:
- Its purpose is identical to r.ApproximateOcclusionQueries, serving as the C++ implementation of the console variable.
- It’s used directly in the engine code to check if approximate occlusion queries are allowed through the IsAllowingApproximateOcclusionQueries() function.
- The value is accessed using the GetValueOnAnyThread() method, allowing it to be safely read from any thread.
- Developers should use this variable when they need to programmatically check or modify the approximate occlusion queries setting within C++ code.
- Best practices include using the provided IsAllowingApproximateOcclusionQueries() function for readability and consistency when checking this setting in code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:90
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarApproximateOcclusionQueries(
TEXT("r.ApproximateOcclusionQueries"),
0,
TEXT("Batch occlusion for a static and skeletal mesh even if there are movable.In general it's more beneficial to batch occlusion queires for all meshes"),
ECVF_RenderThreadSafe
);
bool GParallelGatherDynamicMeshElements = true;
#Associated Variable and Callsites
This variable is associated with another variable named CVarApproximateOcclusionQueries
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:89
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarApproximateOcclusionQueries(
TEXT("r.ApproximateOcclusionQueries"),
0,
TEXT("Batch occlusion for a static and skeletal mesh even if there are movable.In general it's more beneficial to batch occlusion queires for all meshes"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PrimitiveSceneProxy.cpp:116
Scope (from outer to inner):
file
function bool IsAllowingApproximateOcclusionQueries
Source code excerpt:
bool IsAllowingApproximateOcclusionQueries()
{
return CVarApproximateOcclusionQueries.GetValueOnAnyThread() != 0;
}
bool ShouldOptimizedWPOAffectNonNaniteShaderSelection()
{
return CVarOptimizedWPOAffectNonNaniteShaderSelection.GetValueOnAnyThread() != 0;
}