Using a custom property as an image texture

So I’m trying to do something a bit more tricky: I have a rigged character which supports multiple texture designs (skins, clothing, etc). I want the character to be fully customizable via the armature, so I want a bone or object property to control which skin is used on an individual material. This is of course achieved by using drivers in material nodes.

Doing it using a bone is easy: Just use the position of the bone to decide how much to blend in specific textures. I even created sets of 3 bones, which control the R G and B values of nodes so hair can be colorized by posing the armature!

But I’d like to make it possible to easily use custom textures as well, rather than manually specifying a fixed set of images and having a bone control the alpha value for each. So instead I’d prefer adding a custom property on the armature object, where I specify the name of the image texture. That way anyone would be able to select the armature object, go to the Object tab, Custom Properties, and type in the name of the image they want the character to use.

So what is the problem? Well it seems that the Image Texture material node in Cycles does not allow any flexibility when it comes to defining a texture. If I right-click the Image field on this node, I do not get the Add Driver option, so that the field can automatically be set to a property. I’d need something that would allow me to feed a texture defined in a string into the shader node.

Is there any way to do this? Either with drivers, or maybe even with a simple Python script? Thank you.

What can prevent you from connecting 2 or more image texture nodes and drive Color mix nodes instead?

I can do that using a bone driver like I said. But this requires creating an Image Texture node for each texture. My character is intended to be linked as a group, and animated by making the armature a proxy… so the material itself isn’t meant to be edited. This means that you can’t specify your own texture, only use the ones included with the character. If a custom property could be translated into the texture name instead, people would just write the name of the skin… which could even be an image in the blend file the character is linked to.

I went ahead and used a simple bone driver to do the trick. I’m still interested in an answer to this thread however, since if using a string property is possible too that would be useful to know. Also, if anyone is curious how I implemented this:

I created a new bone and gave it a shape similar to a turnable radio button, so the animator can see at which point the texture is changed. I then went into the material nodes: I added a Value input node, and using a driver I made the bone’s rotation control the value. I then added a chain of Image Texture nodes + Mix nodes, each using a Less Than and Greater Than math node to decide whether to blend the texture in. Thanks to node groups, it’s a compact and easily reusable technique, which people will be able to take from my model once I publish it :slight_smile: