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?enter image description here

  • $\begingroup$ Looks like a job for the Object Index pass. I can't answer right now, but I should be able to whip up something later. $\endgroup$ – SilverWolf - Reinstate Monica Jun 3 '18 at 1:00
  • $\begingroup$ Yeah that’d be great! @seaturtle $\endgroup$ – Tyler Dahl Jun 3 '18 at 1:01
  • $\begingroup$ I added a preliminary answer on the Object Index pass. More info coming later about your specific use case (separate images for keys, etc.). $\endgroup$ – SilverWolf - Reinstate Monica Jun 3 '18 at 2:03
  • $\begingroup$ Hey sounds good @seaturtle. That makes sense and thanks for sharing! Will look for the images/letters and get back to you after that as well $\endgroup$ – Tyler Dahl Jun 3 '18 at 2:08
  • 2
    $\begingroup$ @drSybren's answer is better than what I had come up with, which effectively did the same thing in a very convoluted way rather than using the tool that was designed for it. (: $\endgroup$ – SilverWolf - Reinstate Monica Jun 3 '18 at 13:00

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.)

  • $\begingroup$ More info coming later, on different letters/images in specific. I don't have time for that right this moment, though. $\endgroup$ – SilverWolf - Reinstate Monica Jun 3 '18 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.