fx.NiagaraAllowComputeShaders
fx.NiagaraAllowComputeShaders
#Overview
name: fx.NiagaraAllowComputeShaders
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, allow the usage compute shaders within Niagara.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of fx.NiagaraAllowComputeShaders is to control whether compute shaders are allowed within the Niagara visual effects system in Unreal Engine 5. This setting is crucial for the rendering and simulation aspects of Niagara, which is a powerful particle and effects system.
This setting variable is primarily used by the Niagara plugin, which is part of Unreal Engine’s FX (effects) system. Based on the callsites, it’s clear that this variable is integral to the core functionality of Niagara, particularly in determining whether certain GPU-based operations can be performed.
The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. By default, it is set to 1 (true), allowing the use of compute shaders in Niagara.
GNiagaraAllowComputeShaders is the associated variable that directly interacts with fx.NiagaraAllowComputeShaders. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable can significantly impact the performance and capabilities of Niagara effects. Disabling compute shaders could limit the complexity and efficiency of particle simulations, especially for large-scale effects.
Best practices when using this variable include:
- Keeping it enabled (default) unless there’s a specific reason to disable compute shaders.
- Testing performance with and without compute shaders for complex effects to ensure optimal results.
- Being aware that changing this setting could affect the behavior and appearance of existing Niagara effects in a project.
Regarding the associated variable GNiagaraAllowComputeShaders:
- It’s an integer variable used as a boolean flag (0 for false, 1 for true).
- It’s used in conjunction with other flags like GNiagaraAllowGPUParticles and GRHISupportsDrawIndirect to determine if certain GPU-based features are available.
- It’s checked in utility functions like FNiagaraUtilities::AllowGPUParticles and FNiagaraUtilities::AllowComputeShaders, which are likely used throughout the Niagara system to determine feature availability.
- Developers should be cautious about directly modifying this variable in code, as it’s intended to be controlled via the console variable system.
#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:29
Scope: file
Source code excerpt:
int32 GNiagaraAllowComputeShaders = 1;
FAutoConsoleVariableRef CVarAllowComputeShaders(
TEXT("fx.NiagaraAllowComputeShaders"),
GNiagaraAllowComputeShaders,
TEXT("If true, allow the usage compute shaders within Niagara."),
ECVF_Default);
int32 GNiagaraAllowGPUParticles = 1;
FAutoConsoleVariableRef CVarAllowGPUParticles(
#Associated Variable and Callsites
This variable is associated with another variable named GNiagaraAllowComputeShaders
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:27
Scope: file
Source code excerpt:
//////////////////////////////////////////////////////////////////////////
int32 GNiagaraAllowComputeShaders = 1;
FAutoConsoleVariableRef CVarAllowComputeShaders(
TEXT("fx.NiagaraAllowComputeShaders"),
GNiagaraAllowComputeShaders,
TEXT("If true, allow the usage compute shaders within Niagara."),
ECVF_Default);
int32 GNiagaraAllowGPUParticles = 1;
FAutoConsoleVariableRef CVarAllowGPUParticles(
TEXT("fx.NiagaraAllowGPUParticles"),
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:942
Scope (from outer to inner):
file
function bool FNiagaraUtilities::AllowGPUParticles
Source code excerpt:
bool FNiagaraUtilities::AllowGPUParticles(EShaderPlatform ShaderPlatform)
{
return GNiagaraAllowGPUParticles && GNiagaraAllowComputeShaders && GRHISupportsDrawIndirect;
}
bool FNiagaraUtilities::AllowComputeShaders(EShaderPlatform ShaderPlatform)
{
return GNiagaraAllowComputeShaders && GRHISupportsDrawIndirect;
}
bool FNiagaraUtilities::AllowGPUSorting(EShaderPlatform ShaderPlatform)
{
return FXConsoleVariables::bAllowGPUSorting != 0;
}