How to set material in geometry nodes (3.0) based on instance index

After helping someone, I was just playing around with Geometry Nodes in 3.0, and was trying to set each instanced mesh to it’s own material using the “set material index” node. But it doesn’t seem to work or maybe it’s just not intuitive to me. Even without using the index input and just adjusting the numerical value, it doesn’t do anything, even though I have 4 materials and 4 material slots. I would expect each of the icospheres to be a different color based on material 0, 1, 2, and 3. Is this possible? What am I missing?

I don’t think this is the proper way to do it, but it appears to work. Maybe someone with more knowledge will show how to do it with primitives.

Ah I see thanks. But then a different material is applied to each face of an instance, not to the whole instance itself. Is there a way to change it so that setting the material affects the whole instance?

If you look at the file, you should see that the object that is instantiated is the one with the multiple material slots.

Yes I get that, but if you look at the screenshot below, if I try to set the material using the index input and modulo, it doesn’t change every other instance, it changes every other face.

If you are only using one mesh type for your instances (i.e. they all have the same number of faces), you can use the approach here to get a different, single, material per instance:

yep sorry.