Logic node

Iteration

The loop variable. Iteration is a tiny read-only node that lives inside a Loop or Replicator body and reports where the current pass stands: the integer Index, the normalized position T, and the total Count. Everything downstream of it is re-evaluated once per iteration, which is precisely how a container body produces a different value — or a different clone — for every pass.

Outputs

PortType
Indexint
Tfloat
Countint

How It Works

Iteration has no inputs and does no computation of its own. The owning container (Loop or Replicator) writes its outputs directly before each body pass:

OutputTypeValue
IndexIntThe current pass, 0 … N−1
TFloatIndex / (N − 1) — 0 on the first pass, 1 on the last; defined as 0 when N ≤ 1
CountIntN, the container's clamped iteration count for this frame

Because the container seeds these values into the output cache rather than calling process(), Iteration behaves like a register, not a processor. If some pull path does re-process it while a body is running, it answers from the live iteration context of its own container; outside a running body it returns a harmless zero state (Index 0, T 0, Count 0).

Iteration also determines the body's execution split: the container evaluates only the Iteration node and everything downstream of it once per pass. Children not connected (directly or transitively) to an Iteration output are loop-invariant and run just once per frame — so the position of your Iteration cables literally decides what work is repeated N times.

The node is container-only: the palette hides it at root level and offers it only while you are dived into a container whose child policy admits it (Loop and Replicator both do). Placing one at root level is not possible, and a stray one would only ever output zeros.

Parameters in Depth

Iteration has no input ports — it is entirely driven by the enclosing container. Its three outputs are the parameters:

Index (int) — the pass number, starting at 0. Use it for element lookups (Array Get), integer arithmetic (Index × spacing), or as a key when building structures. On the final pass it equals Count − 1.

T (float) — the normalized ramp across the whole run, inclusive at both ends: exactly 0.0 on the first pass and exactly 1.0 on the last. This is the natural input for gradients, interpolation, easing curves, and angles (T × 360 sweeps a full circle across the clones). With a single iteration (N = 1) there is no span to normalize, so T is 0.

Count (int) — the container's iteration count after clamping (Loop caps at 1024, Replicator at 256). Handy for density-aware math, e.g. scaling sizes down as counts go up, without wiring the container's Iterations value into the body separately.

Use Cases

  • Per-element array access: inside a Loop, Iteration Index → Array Get on an array published through the Loop's + port — the foundation of every map/transform patch.
  • Even spacing: inside a Replicator, Iteration Index → Math (Multiply by 0.1) → the internal Circle 2D Position X: ten circles in a neat row from one generator.
  • Ring layouts: Iteration T → Math (Multiply by 360) → Math sin/cos → generator X/Y — N clones evenly distributed on a circle, always closing perfectly because T reaches 1.0.
  • Gradient ramps: Iteration T → Gradient node → the internal generator's Color: a smooth color sweep across all clones of a Replicator.
  • Structure keys: Iteration Index → JSON Object / Make Structure inside a Loop, publishing an array of N records with their own index baked in.
  • Density compensation: Iteration Count → Math (Divide) to shrink each clone's size or alpha as the clone count grows, keeping total coverage roughly constant.

Tips

  • One Iteration node per body is enough — its three outputs can fan out to any number of consumers. All Iteration nodes in the same body report identical values.
  • Keep heavy math upstream of Iteration when it doesn't depend on the pass: only nodes downstream of an Iteration output are evaluated N times, everything else runs once per frame.
  • T is inclusive: first pass 0.0, last pass 1.0. For a seamless ring where index 0 and index N−1 would otherwise overlap (e.g. T × 360 puts a clone at both 0° and 360°), use Index / Count via Math instead of T.
  • Outside a running container body the node outputs zeros — it has no meaning at root level, which is why the palette only offers it inside Loop and Replicator.

Open Iteration in the interactive catalog →

Iteration is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Logic nodes