Loops & feedback
Repeat a piece of your graph — once per element, a fixed number of times, or by feeding each frame's result back into the next.
Sometimes one pass through your graph isn't enough. You want to run the same little recipe a number of times, build something up over a dozen passes, or let a frame react to the frame before it. DNA gives you two tools for that: for-each loops and feedback loops.
Just want many copies of something laid out in space (a grid, a ring, dots along a path)? That's instancing, not a loop — see Copying & instancing.
For-each loops: run a recipe many times
A for-each loop is a Start node, a body of nodes, and an End node. Whatever you build between Start and End runs once per pass, and the End gathers the results.
You choose how many times it runs:
Count — a fixed number of passes.
For Each — one pass per item in whatever you feed in (a list, a set of shapes).
For Each Element — one pass per point, face, or piece of a single shape.
Inside the body you can read where you are: which pass you're on (@index), how many there are in total (@total), and how far through you are from 0 to 1 (@normalized). Use those to vary each pass — nudge a copy a little further, rotate it a little more, tint it a little differently.
At the End node you pick how the results come together:
Collect — gather every pass into a list.
Concat — merge all the geometry into one result.
First / Last — keep just one pass.
Keep the loop body small. Anything that doesn't change from pass to pass (a texture you load, a shape you import) is computed once and reused, so the loop only re-runs the parts that actually vary.
Feedback loops: this frame builds on the last
A feedback loop sends a pass's output back in as the next pass's input. That's how you grow trails, smear paint, run reaction-diffusion, or accumulate anything over time.
It comes in three flavours:
One-Shot — runs a fixed number of passes and stops. Deterministic and repeatable — great when you want the same result every time.
Continuous — keeps its state alive across frames on the timeline. Play the timeline and each frame picks up where the last left off. This is the classic "feedback" look — echoes, trails, things that build up as time runs.
While — keeps going as long as a condition you wire in stays true (with a safety cap so it can never run forever).
Continuous feedback respects your timeline. Scrub backwards or jump around and DNA keeps the result honest — it knows the difference between playing forward and re-checking a frame you've already seen, so edits to your settings still show up without corrupting the build-up.
Continuous feedback has a reset you can fire to clear its state and start fresh from frame one — handy when a trail has filled the screen and you want a clean slate.
Feedback loops work just as well on images and volumes as on geometry. DNA hands each frame's rendered result straight into the next pass for you — no manual ping-ponging, no setup.
Which one do I reach for?
Run a recipe a set number of times, or once per element, and gather the results → a for-each loop.
Each frame should build on the last (trails, sims, growth) → a feedback loop. One-Shot for repeatable, Continuous for timeline-driven.
Many copies of a thing, laid out in space → that's instancing, not a loop — see Copying & instancing.
Loops can get expensive fast. Cap your pass counts, prefer One-Shot feedback when you don't need cross-frame state, and watch the Cook badge on a node — that's DNA telling you how often it's recomputing. A heavy loop that re-cooks every frame is the usual culprit when playback gets sluggish.
See also
Copying & instancing — for many copies, the non-loop tool
loop.for_start
loop.feedback_start