Niagara.GPUCulling
Niagara.GPUCulling
#Overview
name: Niagara.GPUCulling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to frustum and camera distance cull particles on the GPU
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Niagara.GPUCulling is to control whether frustum and camera distance culling of particles should be performed on the GPU in the Niagara visual effects system.
This setting variable is primarily used by the Niagara plugin, which is part of Unreal Engine’s visual effects system. Based on the callsites, it’s clear that this variable is integral to the Niagara module’s performance optimization features.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 1 (enabled) in the NiagaraCommon.cpp file.
The associated variable GNiagaraGPUCulling interacts directly with Niagara.GPUCulling. They share the same value, with GNiagaraGPUCulling being the actual int32 variable used in the C++ code.
Developers must be aware that this variable affects the performance and rendering of Niagara particle systems. When enabled (set to 1), it allows for GPU-based culling of particles, which can significantly improve performance, especially in scenes with many particles.
Best practices when using this variable include:
- Keeping it enabled (default value of 1) for most scenarios to benefit from GPU culling.
- Only disabling it if there are specific issues or conflicts with other rendering techniques.
- Testing performance with and without GPU culling enabled to ensure it’s beneficial for your specific use case.
- Being aware that changing this setting may affect the visual output of particle systems, particularly at the edges of the view frustum or at long distances from the camera.
Regarding the associated variable GNiagaraGPUCulling:
The purpose of GNiagaraGPUCulling is to serve as the actual int32 variable that stores the state of GPU culling for Niagara particles.
It’s used directly in the Niagara module’s code, specifically in the AllowGPUCulling function, which determines whether GPU culling should be applied based on the current shader platform and other conditions.
The value of GNiagaraGPUCulling is set through the console variable system, mirroring the value of Niagara.GPUCulling.
It interacts with other GPU-related features in Niagara, as seen in the AllowGPUCulling function where it’s checked alongside GPU sorting and compute shader support.
Developers should be aware that modifying GNiagaraGPUCulling directly in C++ code is not recommended. Instead, they should use the console variable Niagara.GPUCulling to change this setting.
Best practices for GNiagaraGPUCulling include:
- Treating it as a read-only variable in most cases.
- Using it in conjunction with other GPU-related checks when determining whether to use GPU-accelerated features in Niagara.
- Being aware of its impact on performance and visual output when developing Niagara particle systems.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:43
Scope: file
Source code excerpt:
int32 GNiagaraGPUCulling = 1;
FAutoConsoleVariableRef CVarNiagaraGPUCulling(
TEXT("Niagara.GPUCulling"),
GNiagaraGPUCulling,
TEXT("Whether to frustum and camera distance cull particles on the GPU"),
ECVF_Default
);
int32 GNiagaraMaxStatInstanceReports = 20;
#Associated Variable and Callsites
This variable is associated with another variable named GNiagaraGPUCulling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:41
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_Default);
int32 GNiagaraGPUCulling = 1;
FAutoConsoleVariableRef CVarNiagaraGPUCulling(
TEXT("Niagara.GPUCulling"),
GNiagaraGPUCulling,
TEXT("Whether to frustum and camera distance cull particles on the GPU"),
ECVF_Default
);
int32 GNiagaraMaxStatInstanceReports = 20;
FAutoConsoleVariableRef CVarMaxStatInstanceReportss(
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:957
Scope (from outer to inner):
file
function bool FNiagaraUtilities::AllowGPUCulling
Source code excerpt:
bool FNiagaraUtilities::AllowGPUCulling(EShaderPlatform ShaderPlatform)
{
return GNiagaraGPUCulling && AllowGPUSorting(ShaderPlatform) && AllowComputeShaders(ShaderPlatform);
}
bool FNiagaraUtilities::AreBufferSRVsAlwaysCreated(EShaderPlatform ShaderPlatform)
{
return RHISupportsManualVertexFetch(ShaderPlatform) || IsGPUSkinPassThroughSupported(ShaderPlatform);
}