I want to be able to loop a certain math function (in the node editor) x amount of times. I want to do this without scripting (unless it could be done so while still being able to run on GPU). For instance, if I wanted to take square root of an input, and then then sqrt of that, and so on, x amount of times, WITHOUT just making a big line of nodes, repeating. Anyone know how this could be done?

  • 2
    $\begingroup$ As far as I know there isn't a way to do this in cycles material nodes. That said, you could make a node group containing the body of your loop and "unroll" it by duplicating it with python (a "preprocessor" script if you will). Also, the animation nodes addon has some iteration features, though I doubt you will be able to make much use of them for material processing. $\endgroup$
    – gandalf3
    Jan 31, 2019 at 0:51

1 Answer 1


This can't be done in the node editor alone - the only solution is to (somehow) create the actual nodes themselves. However, there are ways to simplify the creation of the nodes.

One example is to use the Node Expressions (aka Dynamic Maths Expression) addon available from https://github.com/baldingwizard/Blender-Addons/wiki. This allows you to simply type the required expression and the nodes are automatically built within a new Node Group for you.

For example, to generate your example of repeated square-root operations, you could simply enter the expression as :


Where '**' represents 'to the power of' and raising to the power of 0.5 is the same as taking the square-root. Simply edit the expression for as many operations as you desire (ensuring to match up the brackets correctly). The above expression will generate the following nodes :

generated nodes

You can perform various actions in the same way, with the add-on supporting all basic mathematical operations (+, -, *, /) as well as various functions such as 'sin(...)', 'cos(...)', etc. with numerous inputs and outputs (see the accompanying documentation for additional details and examples).

  • $\begingroup$ Secrop's Loop Node, discussed here works in 2.79.. but despite the 2.8 version having received recent attention, I just can't get it to appear as an add-on. Info tells me it's installed, but I get no invitation to enable it, or menu items. If/when you're interested, and/or get any clues, a tip-off would be much appreciated. $\endgroup$
    – Robin Betts
    Oct 23, 2019 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .