I have an object and I made instances of it, but everything is connected, shape & material...etc, how to assign different materials to those instanced objects ??
So, let's see how to illustrate this. We will use this setup :
A cube parented to a plane, then the plane is set to "Instance" its children on each of its vertices. As you noticed you can't directly access the instantiated cubes unless you make the instances "real", but then you can't go back.
Let's circle the "Object info" output to see how we can use it to our advantage to differentiate each of the instantiated cube.
Note : I don't know if this is a bug or intended, but child objects under instancers are not instantiated when using a "Collection Instance" (Add > Collection Instance or SHIFT + A. More on that later.
So the location output takes the XYZ world location of each object's origin. In this case we use it so the XYZ values are translated to a RGB value.
See it in movement :
Put them in a collection and use collections instances (notice that the child cube is not instantiated, is that a bug ?) :
This can be used to individually tweak the objects. You can select it there :
The instantiated cubes will take the color of their instancer, so they will all share the same color. But you can make individual instancers have different colors.
This one works differently, here the instancer does not matter. The instantiated cubes will share the same color as their origin, child cube. The object pass index can be used in the compositor after rendering, too.
Inside collection instances, the effect still works but the child cubes are not instantiated :
I don't see how this could be used here.
This will give you a random value between 0 and 1, per object, including instances. You will have the most variety here, but also the least control over the effect.
When using collection instances, a different value is picked for each object, but each subsequent collection instance will have the same random value. The child object is still missing :
Quick fix, combine the random and position :
For more advanced effects (roughness, alpha value, animation) with these controls see my other answer here : https://blender.stackexchange.com/a/163699/86891