fx.NiagaraStateless.Distribution.OptimizeLUTs

fx.NiagaraStateless.Distribution.OptimizeLUTs

#Overview

name: fx.NiagaraStateless.Distribution.OptimizeLUTs

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.NiagaraStateless.Distribution.OptimizeLUTs is to control the optimization of Look-Up Table (LUT) generation in the Niagara particle system, which is part of Unreal Engine’s visual effects (FX) subsystem.

This setting variable is primarily used within the Niagara plugin, specifically in the stateless distribution functionality. It’s part of the FX system in Unreal Engine 5, focusing on optimizing performance for particle effects.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. By default, it’s set to true (enabled).

The associated variable GOptimizeLUTs directly interacts with fx.NiagaraStateless.Distribution.OptimizeLUTs. They share the same value, with GOptimizeLUTs being the actual boolean variable used in the code logic.

Developers must be aware that this variable affects the LUT generation process for Niagara particle systems. When enabled, it optimizes the LUT generation, which can potentially improve performance but might also affect the precision of particle simulations.

Best practices when using this variable include:

  1. Leaving it enabled by default for better performance.
  2. Disabling it temporarily if you notice any unexpected behavior in particle simulations that might be caused by LUT optimization.
  3. Profiling your game with this option both enabled and disabled to understand its impact on your specific use case.

Regarding the associated variable GOptimizeLUTs:

The purpose of GOptimizeLUTs is to serve as the actual boolean flag used in the code to determine whether LUT optimization should be performed.

It’s used within the Niagara plugin, specifically in the NiagaraStatelessDistribution module.

The value of GOptimizeLUTs is set by the fx.NiagaraStateless.Distribution.OptimizeLUTs console variable.

GOptimizeLUTs directly interacts with the LUT generation process. When true, it triggers the optimization logic in the CurvesToOptimizedLUT function.

Developers should be aware that this variable is only defined when WITH_EDITORONLY_DATA is true, indicating it’s primarily used in editor builds.

Best practices for GOptimizeLUTs include:

  1. Not modifying it directly in code, but rather using the console variable to change its value.
  2. Being cautious when disabling it, as it might affect performance.
  3. Using it as a quick way to toggle LUT optimization for debugging or performance testing purposes.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessDistribution.cpp:8

Scope (from outer to inner):

file
namespace    NiagaraStatelessDistributionPrivate

Source code excerpt:

	bool GOptimizeLUTs = true;
	FAutoConsoleVariableRef CVarNiagaraStatelessDistributionOptimizeLUTs(
		TEXT("fx.NiagaraStateless.Distribution.OptimizeLUTs"),
		GOptimizeLUTs,
		TEXT("When enabled we optimize the LUT generation."),
		ECVF_Default
	);

	TArray<float> CurvesToLUT(TArrayView<const FRichCurve> Curves, int32 NumSamples)

#Associated Variable and Callsites

This variable is associated with another variable named GOptimizeLUTs. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessDistribution.cpp:6

Scope (from outer to inner):

file
namespace    NiagaraStatelessDistributionPrivate

Source code excerpt:

{
#if WITH_EDITORONLY_DATA
	bool GOptimizeLUTs = true;
	FAutoConsoleVariableRef CVarNiagaraStatelessDistributionOptimizeLUTs(
		TEXT("fx.NiagaraStateless.Distribution.OptimizeLUTs"),
		GOptimizeLUTs,
		TEXT("When enabled we optimize the LUT generation."),
		ECVF_Default
	);

	TArray<float> CurvesToLUT(TArrayView<const FRichCurve> Curves, int32 NumSamples)
	{

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessDistribution.cpp:67

Scope (from outer to inner):

file
namespace    NiagaraStatelessDistributionPrivate
function     TArray<float> CurvesToOptimizedLUT

Source code excerpt:

	{
		TArray<float> LUT = CurvesToLUT(Curves, MaxLutSampleCount);
		if (GOptimizeLUTs)
		{
			for (int32 iSamples = 2; iSamples < MaxLutSampleCount; ++iSamples)
			{
				TArray<float> NewLUT = CurvesToLUT(Curves, iSamples);
				if (AreLUTsAlmostEqual(NewLUT, LUT, Curves.Num()))
				{