3
$\begingroup$

I'm almost certain the answer is going to be no, but is there a way of a node group being recursive? That is, the node group somehow includes a copy of itself. Say you have a node group that creates a branch on a tree. The resultant branch might have sub-branches, and they might have sub-branches and so on. Without recursion you need to specifically add each of the branching levels, basically hard-coding the number of levels of sub-branch. With recursion you'd create a branching node group, and inside it you would call itself to create the sub-branches and so on, until you hit some limiting factor. Of course without some limiting factor this would inevitably lead to an out-of-memory error, which I'm guessing is maybe a reason why it doesn't exist. Of course you could have recursion limits built in, like in the Javascript engines in browsers that only let you do a few thousand levels of recursion. Given the way that geometry nodes are increasing looking like a proper programming language (somewhere someone is totally porting Doom to run on geonodes) this would be a useful feature. the error message saying no recursion allowed

$\endgroup$
3
  • 3
    $\begingroup$ Do you know about repeat zones? $\endgroup$
    – TheLabCat
    Commented Nov 8 at 0:05
  • $\begingroup$ Yes, repeat zones are not recursive, in that they don't nest an operation inside itself. If you have a repeat zone it's like branch(), branch(), branch()... with recursion it's branch(branch(branch(...))). $\endgroup$
    – stib
    Commented Nov 8 at 0:34
  • $\begingroup$ You can have recursive subdivision as an example. $\endgroup$ Commented Nov 8 at 0:39

1 Answer 1

4
$\begingroup$

This is an exemple of "fake" recursion achieved with "Repeat Zone" to make a fractal cubes on cube's vertices.

enter image description here

enter image description here

Key Concepts

  • A stop criteria with a "switch". I used a maximum level (index), but you could use any other criteria. If stop criteria reached, output the original geometry for this iteration, else, output your node setup
  • A separate output for the "current geometry" and the "full geometry".
  • We work with the "current geometry" and join the results into the full geometry

Alternative storing recursion levels

This might be useful in some cases, but not for this simple example.

  • We can store at each geometry the recursion level at which it was generated, for selection, inspection and other uses.

enter image description here

$\endgroup$
3
  • $\begingroup$ I like the idea of storing the recursion level as a named attribute, that's a good workaround. $\endgroup$
    – stib
    Commented Nov 8 at 1:30
  • 2
    $\begingroup$ @stib In 4.3 the Repeat Zone gets an Iteration socket so that you can directly read out the level without having to store it explicitly (unless you want to modify it inbetween). $\endgroup$ Commented Nov 8 at 5:37
  • 1
    $\begingroup$ Yes, the iteration socket is going to simplify things a bit. It's kinda what inspired the question. Geonodes are behaving more and more like a programming language. $\endgroup$
    – stib
    Commented Nov 8 at 6:56

You must log in to answer this question.

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