MGL distinguish two types of scopes:

  • Serial
  • Parallel

Serial scope

Statements with host variables or input-output operations are performed in serial scope. This type of expressions are handled in a single thread:

int i = inInt[0];
vector v = inVector[0];
outVector[0] = v;

Parallel scope

While performing operations on a point set, interpreter enters into a parallel scope. Statements that involve a point field are executed simultaneously, one thread per point instance:

vert p = inMesh[0]; // Serial scope
p.position.x += 1; // Parallel scope
if(p.position.x < 0) // Parallel scope
    p.position.y += 1;
outMesh[0] = p; // Serial scope

Because per-particle operations are executed simultaneously, it is forbidden to make an assignments from parallel scope to host variables.

Previous: Default variables and point fields | Language reference | Next: Built-in functions