1
$\begingroup$

or rephrased: is it possible to have the switch node result emulate the way a diode works?

I often times find myself in need of a way to accumulate the number of occurrences of a condition being met, and each time I find out accumulate field is not what I'm looking for as the input and output are of a non-field type. It might not be possible but I can't be sure.

Pictured below demonstrates what I mean. The boolean (imagine it's the result of a group input or comparison) starts at 0, when switched to true it gets converted to a value 1 and added to the result of its original state (0), switching back to false returns its previous state (1) repeat until the reset switch condition is met to start it from the original state again. Clicking the comparison count 6 times would result in 3, clicking reset twice would reset it.if it were not for the feedback loop limitation this would be sound

no blend file I'm afraid, just asking so I don't blindly sink hours into a dead end project idea.

$\endgroup$
5
  • $\begingroup$ "clicking reset twice would reset it" - by design nodes don't interact like that. A node tree is a "dead" description, a program; clicking the checkbox twice cannot change how the program works, as the 2nd click nullifies the first, the program is changed by the first click, but restored with the 2nd click. Perhaps your problem can be answered if you can redesign the question to not concentrate on the interface part (clicking the checkbox), but instead described some kind of iterable state, like having a mesh line with a bool attr. and wanting to do something with every 2nd "True" in a row. $\endgroup$ Commented Feb 12, 2023 at 12:19
  • $\begingroup$ @Markusv Thanks for the response. You're right, my focus on the interface is mostly irrelevant. You've given me a clue as to why it isn't possible with the dead description part, I'm interested in understanding the limits. You also mention using a mesh line with a bool attribute. From what I understand (correct me if I'm not) the result of a non-field value isn't stored in the node like a variable, but field attributes can be stored in geometry. They can be used later in the tree but not earlier, and field attributes can only be "mixed" with other geometry where the number of IDs are equal. $\endgroup$ Commented Feb 13, 2023 at 23:12
  • $\begingroup$ A node tree is parsed and run by an interpreter similarly to how a Python script is executed by a Python interpreter: if you have code in state A, change statement var = False to var = True (now state B), and again change it to var = False, you effectively returned to the state A. The interpreter doesn't maintain some kind of meta information like the history of the code. Of course it's different if you explicitly somehow output that "meta" information, e.g. in the example here I unmute and mute a node to reset the simulation. $\endgroup$ Commented Feb 13, 2023 at 23:51
  • $\begingroup$ Attributes are stored in the geometry. The chronological order of the evaluation is tricky to get, I explain it here and here. One missing thing there is that you can treat a circular socket as a cached data, so arrows are allowed to go through it only once left, and once right, then you can think of it as cached data, as if the entire tree branch going from this socket to the left was replaced with e.g. a single float value for a green circular socket 🖤. $\endgroup$ Commented Feb 13, 2023 at 23:55
  • $\begingroup$ Hay I just came back to say that the experimental simulation nodes are exactly the kind of self referencing instruction functionality i was looking for, supposedly animation nodes might do something similar. It's quite hard to manage the context evaluation in the newer versions it seems but it opens a lot of doors to my older projects that died from a lack of this. I did know at the time nodes can be iterative not not recursive, I just didn't know where that applied fully when I was new to geometry nodes. $\endgroup$ Commented Mar 13, 2023 at 1:01

0

You must log in to answer this question.

Browse other questions tagged .