Combining materials that already has UV coordinates

I have 4 models that has separate materials and each models already have UV coordinates.

I want to combine these models to using single material for better performance in games.

Current what I do is just import all models in single Blender file and change to use single material and remap the UV coordinates of each 4 models to take each takes 1/4 of texture space.

This actually works, however there are some lots of precision lost, also it took so much time to make texture each time.

Here’s my workflow for this:

  1. Import all models in single Blender file
  2. Remove all materials and create new one and apply to all models
  3. Update UV coordinate of each model to take 1/4 spaces of texture space.
  4. To do that, first I scale down to .5(50%). If texture is 1K size, it should be 512x512.
  5. Move -256px of X and Y. But here’s the problem, this is always incorrect position(I don’t know why). Mostly I just move the whole uv coordinates to find better position.
  6. Repeat 4~5 until 4 models done.
  7. Save combined model and

make new texture from 2d graphics program, such as photoshop.

Is there a shorten way to do this, or is there a better way to do this? It will be really appreciate it give me some advice.

It all sound about right, except I would START by making your new texture in Photoshop/Gimp/Whatever.

Also, when scaling the UV coordinates, make sure you are scaling to the Cursor and the cursor is in the bottom/left corner of the texture. I think this is the problem you may be having.

I think you can use Texture Atlas addon which comes within Blender. That should automate some of the things you are doing manually.

Not sure what exactly the effects are that cause better performance in games, in particular as I don’t know what you are using there and how. So can’t say whether the suggestion below is of help.

Just from workflow perspective, what I do in such cases is to put all the material definition except for the image textures into a node group. Then still use per-object materials but these only consist of the different UV-mapped image textures fed into the (shared) node group. Voila, different image textures, but otherwise same material.

In case it is important to merge all textures into one image, the approach can be adapted by putting the image texture also into the node group and doing in the materials outside of the group just the UV remapping, using a Vector Mapping node.

Thanks but 2D cursor is always bottom left corner. But still, scale to .5 and moving exact (-256,-256) is inaccurate.

Thanks! I should try with that. However I need to make some variation of the texture, something like replaceable skins. In my current workflow, I just grab the different painted texture into current combined texture so I can get different texture. To achieve same goal with Texture Atlas, shouldn’t I bake the texture every time?

I’m using Unity Game Engine. In this case, each material requires one or more draw calls. That’s why I’m trying to combine multiple current exists materials to single one.

You bake only once after the addon combined meshes.

Workflow with that addon is:

1- Create UVs for each object seperately
2- Select objects, click + button at Texture Atlas section and create image size
3- Select “StartManualUnwrap”. (This will automatically hide seperate objects and show you combined object. Check outliner for this.)
4- Modify UV of combined mesh not to overlap. (Smart UV project)
5- Bake your texture
6- Select “FinishManualUnwrap” and you’re done.

Ah, I see. According to the docs, it seems to really need combined textures.

The way I see it, your problem consists of 3 parts:

  1. to combine the multiple image textures into one.
  2. to move and scale the UVs.
  3. to adapt the sizes of the textures/UV to the needed detail levels of the different objects.

Suggestions:

  1. Quite trivial to do on the command line, e.g. with ImageMagick. It is just a single command, which you just have to re-execute when you change something in one of the original images.
  2. Also easy if you can script in Python. Should just be a few lines of code. Surely someone already did it. Or if you don’t want that, figure out first what is going wrong in your step 5, so you can save yourself the trouble of manual fine-tuning. It must have a simple reason why it doesn’t work.
  3. Less trivial. If you want that, you probably really should go with a suitable addon.

Thank you for detailed explanation. Definitely try it!

Thanks! I’d better to learn Python and try to automate my workflow.