Add value readable by Emitters to FNiagaraSystemParameters

We would like to add a custom value for “SystemOverlaps” to FNiagaraSystemParameters to be readable from our emitters. This value would be used reduce our emitter spawn count to zero to eliminate spawning any particles for performance/overdraw reasons.

Do you see any particular risk with adding our data here, taking the place of one of the padding variables at the bottom? Or, is there a more appropriate or smaller divergence we could make to still access this information from the emitter?

// Any change to this structure, or it’s GetVariables implementation will require a bump in the CustomNiagaraVersion so that we

// properly rebuild the scripts

// You must pad this struct and the results of GetVariables() to a 16 byte boundary.

struct alignas(16) FNiagaraSystemParameters

{

#if WITH_EDITOR

NIAGARA_API static const TArray<FNiagaraVariable>& GetVariables();

NIAGARA_API static FSHAHash GetStructHash();

#endif

float EngineTimeSinceRendered = 0.0f;

float EngineLodDistance = 0.0f;

float EngineLodDistanceFraction = 0.0f;

float EngineSystemAge = 0.0f;

uint32 EngineExecutionState = 0;

int32 EngineTickCount = 0;

int32 EngineEmitterCount = 0;

int32 EngineAliveEmitterCount = 0;

int32 SignificanceIndex = 0;

int32 RandomSeed = 0;

int32 CurrentTimeStep = 0;

int32 NumTimeSteps = 0;

float TimeStepFraction = 0.0f;

uint32 NumParticles = 0;

int32 _Pad0;

int32 _Pad1;

};

Hi David,

That would work fine adding it there, the structure is now hashed and used in the DDC key. So if we were to add something and you need to resolve it should work fine. Worst case you might have to bump the script version, but that hopefully isn’t the case anymore.

Thanks,

Stu

That seemed to work. While reviewing all the places needed to add the parameter, I noticed this place in code that did not seem necessary to get the param working. Is this location also necessary to update?

BEGIN_SHADER_PARAMETER_STRUCT(FSystemParameters, ) in Engine\Plugins\FX\Niagara\Source\NiagaraShader\Public\NiagaraShader.h

If you using an existing Pad slot then it’s fine, we keep this up to date so we know what’s in here.

If you were to need to extend the structure size it needs to be here to keep the parameter up to date.

Cheers,

Stu