fx.NiagaraAllowComputeShaders

fx.NiagaraAllowComputeShaders

#Overview

name: fx.NiagaraAllowComputeShaders

This variable is created as a Console Variable (cvar).

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:

  1. Keeping it enabled (default) unless there’s a specific reason to disable compute shaders.
  2. Testing performance with and without compute shaders for complex effects to ensure optimal results.
  3. Being aware that changing this setting could affect the behavior and appearance of existing Niagara effects in a project.

Regarding the associated variable GNiagaraAllowComputeShaders:

#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;
}