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:

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:

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:

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?

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