2
$\begingroup$

I have a mesh in which each face have a material assigned. There is a list of collections that the geometry node takes as input. I want to transform faces to points, and instantiate randomly elements of a collection. The collection is chosen depending on the material (index) the face has.

The problem I have is the switch node.

enter image description here

I suppose the reason is that "Material index" is a field, and the switch node does not accept it. No idea why, whether it is a bug or a feature for the future.

The question is, how to select this or that collection depending on the material index?

Using "Collection Info" node to "convert" the collection into a Geometry makes no difference.

Thanks in advance!

$\endgroup$
4
  • $\begingroup$ This is no bug or a future feature, the switch only accepts single values as input depending on what kind of type you choose - some accept fields, but some don't. For example Geometry. The Geometry inputs and output take a geometry in its entirety, so you cannot switch multiple times for parts of the geometry. To put it simple, this is the Geometry Nodes equivalent of Object Mode, not Edit Mode. You can only get one boolean value and that switches the geometry as a whole. $\endgroup$ Commented Sep 6, 2022 at 9:08
  • $\begingroup$ @GordonBrinkmann I am not intending to switch between parts of a Geometry. Simply choose Geometry A (False field) or Geometry B (True field) depending on the Switch condition. Following your analogy, it is like if I select one object or another. I still see no reason why it does not work. It probably has to do with the guts of Blender and how things are coded. I can imagine a couple of design scenarios where it would have the current behaviour. $\endgroup$
    – ditiem
    Commented Sep 7, 2022 at 0:04
  • 1
    $\begingroup$ As I have understood the question the Material Index puts out a field of values. Now if you enter the index 0, let's say the the switch chooses Geometry A and sends it to the output. Now comes index 1, and maybe this selects Geometry B. But where to go with B? The output already has A assigned. As I said, it puts out a geometry entirely, not parts. So you cannot have A here, B there because it's all one complete geometry and it gets A and B as complete geometries. So the output can only be one of them. $\endgroup$ Commented Sep 7, 2022 at 4:30
  • 1
    $\begingroup$ @GordonBrinkmann Thank you. I think I did understand now how the geometry nodes works. I was thinking in declarative paradigm rather than imperative. $\endgroup$
    – ditiem
    Commented Sep 7, 2022 at 11:35

1 Answer 1

3
$\begingroup$

If you want to instantiate different objects from different collections depending on the "material_index", then you would have to solve this as follows:

enter image description here

First you capture the "material_index" with Capture Attribute, and choose this value as Selection during instantiation.

Since a collection cannot be resolved recursively, but always offers only the first children below it as individual objects, you would have to perform the instantiation in parallel.

Unfortunately, there is currently no other option, because nested collections are not supported in Geometry Nodes.


(Blender 3.2+)

$\endgroup$

You must log in to answer this question.

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