PopcornFX v2.9

Generic selectors
Exact matches only
Search in title
Search in content
  1. Home
  2. Docs
  3. PopcornFX v2.9
  4. Scripting reference
  5. Namespaces
  6. eval


The eval namespace contains compile-time directives to change the evaluation rate of an expression.
They allow you to specify if a specific expression should be evaluated at spawn or evolve, or at a lower update-rate.
They are the script equivalent to changing a node’s ‘SimulationState’ and ‘EvolveRate’ properties.


Return typeDescription
Evaluates expression a at spawn (once when the particle is born)
Evaluates expression a at evolve, full rate (every frame)
Evaluates expression a at evolve, high rate (less often than ‘full’ rate)
Evaluates expression a at evolve, medium rate (less often than ‘high’ rate)
Evaluates expression a at evolve, low rate (less often than ‘medium’ rate)
#eval.as(a, b)
Evaluates expression a at the natural rate of expression b
It will NOT downgrade the rate, if a already has a rate higher than b



Sometimes when creating scripts, you want some expressions to be evaluated at evolve, without necessarily making your entire script node run at evolve.
This is often the case when reading things that vary with time, for example the particle age or life-ratio.


The following script will run entirely at spawn time:


float sizeVar = rand(0.5, 1.0);
float t = 1 - self.lifeRatio; // self.lifeRatio evaluates to 0 at spawn
Size = sizeVar * pow(t, 0.5) * 0.1;

And because self.lifeRatio is zero at spawn by definition, the output Size will never change.
Making this script node run at evolve will also make the rand() function run every frame, producing a flickering size.


The solution here is to either split the script into multiple nodes, and use the self.lifeRatio node, which is by default evaluated at evolve, or to keep everything in a single script and use the eval.full() function:


float sizeVar = rand(0.5, 1.0); // evaluated at spawn
float t = 1 - eval.full(self.lifeRatio); // self.lifeRatio will be evaluated every frame
Size = sizeVar * pow(t, 0.5) * 0.1; // sizeVar * 0.1 evaluated at spawn, the rest which depend on 't' at evolve
Was this article helpful to you? Yes No

How can we help?