I would like to have a conditional fork in my geometry nodes logic, based off index. In programming it would be like if (index == 5) { ... }. How are conditional branches or forking done in blender? How do I select a path through my nodes based off index?

In terms of research, I found a similar question, but the way it does conditional selection is through a "selection" input on a "Instance on Points" module. I don't think I need (or want) the "Instance on Points" module as it seems to bring in other geometry. There's another question that also answers with this module here. Maybe it's the only way.

I also tried switch node, but had a circle can't connect with diamond situation. enter image description here

The node I think I'm looking for is a boolean controlled pass-through. It has an in, an out, and a boolean input to decide whether what's coming in goes through.

EDIT: found a proposal for that node and the current workaround (I think) https://blender.community/c/rightclickselect/18bbbc/?sorting=hot

  • 1
    $\begingroup$ Have you tried Separate Geometry? $\endgroup$
    – quellenform
    Dec 4, 2023 at 8:49
  • 1
    $\begingroup$ It was the first thing I tried. I didn't find it to be a very elegant solution. I had linked geometry and a lot of drivers to try to make things work. Coming from a programming background, it makes more sense to me that -- if I want a conditional -- I should use conditions. $\endgroup$
    – Seph Reed
    Dec 4, 2023 at 15:00
  • $\begingroup$ ...correct, but you cannot switch geometry in this way. What exactly do you want to do? Do you have a specific example? $\endgroup$
    – quellenform
    Dec 4, 2023 at 15:05

2 Answers 2


You can conditionally select an index within geometry nodes just as you are doing. You could send this selection that you have, via your math node, to any number of operations that operate on selections. What you cannot do is send a selection to the switch input of a switch node.

You say you're from a programming background. Cool, nodes are just a graphical programming language. Switch is a function. We can write it out in pseudocode if we want:

geometry Switch(bool Condition geometry outputIfFalse geometry outputIfTrue) {
 if Condition return outputIfTrue else return outputIfFalse; }

That's really simple, right? It doesn't do any mixing between the geometry. It doesn't join. It's not overloaded with a bunch of specific cases in case we send it different types of parameters.

You have a variable called DuplicateIndex. This variable is an array of integers. Because you have two instances, this is an array of size 2.

"Less than" is another function. This is an overloaded function that can take multiple kinds of inputs. It can take an array as an input, in which case it outputs an array of booleans; or, it can take just a float or integer or something, in which case it outputs a single boolean. We are sending it an array, so it is outputting an array as well.

But we can't call switch with an array parameter for its boolean input! There's not any way to reasonably cast an array of booleans to a boolean. Our compiler throws an error. In this case, that warning manifests as the red line from result to switch input, indicating GN's version of a type mismatch.

What would we do if we want only the instances with an index less than six? (Which is all of them.) We might call Separate Geometry. Here is roughly what that does, in my pseudocode:

geometry SeparateGeo (geometry InputGeo, array of booleans Selection) {
 geometry OutputGeo = InputGeo.duplicate();
 for which in Selection {
  if (not which) OutputGeo.delete(OutputGeo.points[which]);}
return OutputGeo;

Separate Selection is a loop of conditionals. Most GN operations are loops, and anything with a "selection" input is a conditional. Unlike Switch, it accepts an array of booleans as an input. If you want to send something an array of booleans, you can use it, and you can't use Switch.


I think the reason a switch geometry doesn't work with fields (geometry-context based data) is because there are two contexts, and it could turn out that it wouldn't be a switch node but rather a join geometry node with a pass-through condition [This might be what you want, but that doesn't fit with that nodes function].

The solution is to either use Delete Geometry, which is an inverse "pass-through" node, or use a Separate Geometry, which is just a delete geometry that gives you both sides of the selection.

I think for you (if I understand you correctly) is to use a delete geometry with the selection inverted (use a Boolean Math set to not).

  • $\begingroup$ Delete geometry is awesome for this use case. It's exactly a passthrough, just with the boolean inverted. $\endgroup$
    – Seph Reed
    Dec 6, 2023 at 4:52

You must log in to answer this question.

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