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?
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 :
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).