How to Merge Textures and Export Materials UVs Either as Individual Files or a Layered TGA/PSD?

All right, everyone.

Here’s what I need to do. I have an armor and it has like 20 different materials but only two textures.

That’s way too many.

So what I need to do is to reduce all those into one material and texture. I figured out how to merge materials, you go to the Material tab, select all the materials that use the same textures and merge them.

All is well and I now have two materials, one for each texture.

What I’m trying to figure out is how to merge both of these textures into one. I heard of Baking them and that works, but then the UVs are all over the place and I don’t know anymore which is which.

What I would like to do is before merging all the materials, to somehow bake both the textures into one, then be able to export all materials UV coordinates into single files containing only their part of the texture so I can put them together in Photoshop or something, so when all is merged I can still have a PSD file where I can change colors of certain parts of the armor and export a brand new texture.

I assume you use image textures (not procedural)?

What about this:

  • use an image editor combine both textures into one image, placing them side-by-side
  • in UV editor select all faces using the second material and move them to the right (out of the bounding box of the rest of the faces, belonging to the first material)
  • in your material definitions, add vector mapping nodes between the UV input and image texture nodes. Use these to match up the coordinates to the new UVs and combined image

The last step is probably easier if you do the moving of the UV faces by an exact value.

1 Like

Thank you so much for answering.

I tried your method and it works… Well, at half. The UVs are stretched when I change the texture.

However, that’s not exactly what I’m looking for.

In fact, I want to bake both the textures into one and retain the same UV shapes. It’s so I can change the materials and then bake a new texture and it retains everything in place.

Let me try to explain it better.

See, I have a set of armor for a game I am making. The in-game armor, I want it as One Material, One Texture.

That armor, however, have different variations. Steel Armor, Bronze Armor, Gold Armor, etc.

In Blender, I have the armor done and everything. It has 20 materials for the trims, sleeves, torso, details, buckles, etc.

I want to be able to modify the Blender Armor, bake the texture, then drop the texture into Unity and the Game Armor magically takes it and works.

I’ve tried a few things. Texture combining like you said, I’ve tried baking it but the results always comes black and the UVs are all over the place, with thin lines everywhere and each time it’s in a different place. I’ve tried Texture Atlasing but it erases all the materials and the UVs are not the same in this again.

I’m out of ideas.

Sorry, but I think I have to ask again for clarification. What’s the reasoning behind baking? If you have one image with both textures side-by-side and matching UVs, shouldn’t it work to import that into Unity as is, without any further steps?

Two remarks, though:

  • Stretching of the textures is expected when the image is replaced by one with a different aspect ratio. But this is just a matter of one scaling operation (in x-direction), no?
  • The thin lines, are odd. Are they around UV faces on the ‘outside’, with no neighbors? If Bake -> Output -> Margin is set to 0, it would happen, but I guess not, as default is >0. If you post a blend file, I could check why (maybe you produce the issue on a stripped down model, if you don’t want to share the detailed armor).

It’s for ease of use. It’s so I can easily swap the texture on the armor when needed without having to go through 20 materials or making 12 copies of the same armor but with different material/texture setup.

If I have one armor with one material and one texture, I set the material once, then I can just swap the texture on it whenever I need to.

I managed to un-stretch the UVs manually with scale and move.

So right now, I have the armor and its 20 materials using only one texture. So far, so good.

I also tested it by merging all the materials. Again, so far, so good.

Now, I’m seeing if I can change the materials themselves into other colors and then bake a completely new texture that fits the old one with its UVs and everything in place. When I tried that a little while ago, it came black again.

I’m going to go ahead and set your first reply as the solution. Since it kinda fixed my immediate problem. All materials are now using one texture and I can (in theory and practice) edit each part of the armor individually, even though in result it’s another problem.

Ah, okay, I guess now I got it. You want to change the look with material nodes, not with editing the image texture?

Hmm, baking likely is the way to go then. UVs being all over the place cannot be avoided, if the materials are all over the place also.

But the black lines should be fixable. It’s just hard to diagnose without a blend file.

It’s not black lines. It’s the whole thing. It bakes everything black.

The UVs being all over the place was due to UnWrap and projection. Since we manually fixed those, that’s not a problem anymore.

I can see it baking where the UVs are supposed to be, but it’s all black.

I think maybe it’s a problem with lights, I’ll have to test.

Yes, I’d also guess it’s something simple. You can try to bake something that does not depend on lighting - like, e.g. normals - to check.