Make sure to limit the random value to the max number of materials you’re using (otherwise there would be too many occurrences of the last material). The problem I have is that each face gets a separate material and not the whole instance. I’d like to know if there’s a solution for this.
As a workaround you can duplicate the instances you want to use and each would use a different material. Then instead of using object instances, you would use collection instances with random object from it.
I don’t know how to do it with the setup you have there but if you use an object info node and get an object from the scene… The material index in this case appears to reference the position (slot) in which the material resides. So you are referencing the material index of an object (the instance) with two materials, the second is 1. Check out this blend, for 3.1
You can use the same principle on whole node tree sections with greater than math nodes. Just check if the random number is greater than a certain value, and if it is send it down a different node tree section.
If you have a bunch of objects e.g. rocks, then you add randomness as above, in the Material, and use the Geo node editor to change the physics e.g. object rotation.
If you have multiple materials, then you may want to create a collection e.g. of different stones (brown, gray, crunchy, shiny, etc…) and instance the collection, again Material controls texture randomness (also displacement if you want), while geo nodes control physical object attributes, e.g. rotation, size, etc…
I am not sure if you can randomize whole BSDF Shaders in one material (which to pick, e.g. set Randomness into Fac of a Mix Shader node maybe? ), but even if you could, you may be better off with a collection, some different Materials assigned.
If you tell us, what the exact aim is, I’m sure we can figure something out
Thanks! Year you are right! At that moemnt i didnt know too much about Blender workflow and GN but now what you say it makes sense to have a collection with objects of different colors and then redistribute it using the nodes. Then having access to face level materials is important for non instance objects and other effects.
Another way is if you count the number of faces and use it in the random number generator to assign materials as series which fit and cover each object.