# Different image textures for one material (Cycles)

With Blender Internal (2.79 and older), you can add a UV layer, assign images to each face, Then enable the materials Face Textures option.

Is there some way to to have a single material and multiple images assigned to different faces with Cycles?

I'm asking this because I'm writing an importer for a format that stores textures and materials as 2 separate values per face, if this is not possible I'll have to split up the material per texture, so I can workaround it if its unsupported.

Update 1): As has been suggested you can blend between shaders, this works OK for switching between 2 images, however I can't see a good way to do this with 10+ images (probably its possible with a large node setup and mapping nodes, but this becomes quite cumbersome).

Update 2): I've accepted one of the answers, however using blending like this is quite hard to control and not simple to just assign arbitrary images per face (as part of an importer), so I'll likely have to split up the materials per-texture.

The standard way of allowing multiple images to be applied to a mesh in a single material is to use the mix value between two shaders.

This would either need an extra image per texture to act as a mask or you could use the alpha channel of the texture if it had one.

Below, the top image is a red square (aligned to a single face of the uv's) with an alpha channel and below it a solid blue texture, being mixed using the alpha channel of the red texture as the factor (fac).

Which results in:

So you can assign a texture per face, but to my knowledge it either requires another image to act as a mask or an alpha channel to work.

Unless you can generate such a mask per face, in your script, or all images always have alpha channels marking their borders, this probably isn't going to be a viable solution.

Similar to the other answer, this method can also be simply extended by simply adding another mix shader for every extra image texture you wish to add. This allows as many textures as necessary to be used within the limits of the cycles texture limit. As per Greg's comments below, I have replaced the mix shader with mix rgb to be more efficient.

Note: In the image above I only use 4 textures to save time. So I use the blue texture (covers the whole uv area) as the base colour. The base colour should be the first image in the node tree for this method to work.

• Using so many diffuse shaders is inefficient - for each shader node it has to calculate the shading on that surface. Instead, simply use the Mix RGB node to mix the colours before plugging it into the final single diffuse shader. i.imgur.com/iMyPaOC.png – Greg Zaal Aug 5 '13 at 10:12
• @GregZaal Thanks Greg, hadn't thought about the efficiency of this, updated the answer as per your suggestions. – Ray Mairlot Aug 5 '13 at 12:02

You could assign a Vertex Color layer for each texture. Then use the Attribute and RGBMix nodes:

To cut down on layers you could use a channel per texture:

Separating colours from a single layer can be done too but it's a little more complicated:

• Damn that's good. – Ray Mairlot Aug 2 '13 at 17:10
• Can this work if you want to have 3+ materials? – ideasman42 Aug 2 '13 at 17:38
• I couldn't be sure about the use of that node group, but I've used as many as 12 different colours for texture assignments before. The idea is just to isolate that colour using math nodes, colour ramps, Separate RGB and HSV nodes (which we now have thanks to Thomas ;) ) and using that as a mask/fac for the mix node. It's not much fun. A future possibility to allow something like this is implementing something like Object Indexes for each face. – Greg Zaal Aug 5 '13 at 12:53
• The attribute link is broken. – Steve Buzonas Sep 25 '17 at 11:20