I just had a quick question. I am starting to get a bit more adequate with Blender in terms of getting to photorealism. In the picture below is a model that I got online and I am wanting to edit the material for the keys to make them look more photoreal. My question, is if there is a way of automating the material so that after I have one photoreal material on one key it will do it for the rest of the keys? I know that I can make one material, assign that for all of the keys, and go in and change the images for each one but I feel like there is a way to automate this with python. Any thoughts?
I would use two UV maps for each key. One is shared between all keys and maps to the key texture without letter. The second is a different UV map for each object, with one big texture containing all the key letters; having a different UV map for each key, each gets their own letter. No need to worry about the material itself then.
You can even use the UV Project modifier to project the letters on each object; no need to manually make all those UV maps.
It sounds like you want to use the same material on multiple objects, but be different on each object. You don't need Python for this.
What you need is the Object Index pass.
To set it up, go to the Object properties (the cube) and change the Pass Index, for example 0, 1, 2, and so on:
Then use the Object Info node to do something with it in your node tree. For example:
Which gives this result:
(The Multiplexer node is a node group that acts like a Mix node with more than two inputs. More info in my question here. You don't need it, I just found it helpful.)