[Blender]How to combine several textures into one (Atlas)

Want to increase or share your knowledge? Do it here.
Post Reply
User avatar
keltwookie
Site Admin
Posts: 141
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

[Blender]How to combine several textures into one (Atlas)

Post by keltwookie » Sat May 26, 2018 6:25 pm

The problem occurs when you wish to export textures to third-party game engines. Indeed, when you have a large number of images due to the many meshes that sometimes make up a model, it seems obvious that combining them all into one seems THE solution.
This is called an "Atlas" texture. Indeed this one will include all the textures + UVmaps that you could have added.

Note :
I will only develop here the case of a diffuse texture, simply because the effects of shine, reflection, blurring and others will be made from the engine to which these textures will be exported. That said, it is strongly recommended to make a normal map using the same method.


To make this atlas, you will need two things:
  • UVmaps of each part of your model with a different texture.
  • The image textures you use.

Baking textures

Note :
It is assumed here that all your materials are already created.


A little reminder to make an UVmap:
  • Share your viewport in half if not already done. In one of the views, choose the "UV/Image Editor" view.
  • In the UV editor, create a new UVmap ("+" button), name it for example "texture01.uvmap".
  • Return to the 3D view, switch to edit mode and select the entire mesh.
  • Hit « U ».
  • Select « Smart UV Project », leave the other options by default then validate.
The baking itself:
  • First select your material from the appropriate tab.
  • Return to the "UV Editor" view and split this viewport in two. In one of the two, choose the "Node Editor" view.
In this new viewport you should have at least 3 nodes connected if you used an image texture.
  • 1 Texture image node (Shift+A→ Textures → Image Texture.).
  • 1 Diffuse BSDF node (Shift+A→ Shader→ Diffuse BSDF).
  • The Material Output node.
Image

Note :
Using shaders instead of images for textures could give undesired results and I discourage the use of them for this tutorial.
We could perfectly replace all of this by a simple diffuse BSDF with the color of our choice.


  • In the Node Editor view, Add another Image Texture node.
  • Into this new node, select your UVmap, in our example: texture01.uvmap
Image

Note :
In the current state of the operation, you could add a diffuse BSDF node to this new image texture and link it to the output of your material, allowing you to paint the texture directly onto the mesh.

  • Now, go to the "Render" tab and scroll down to "Bake".
  • Select "Diffuse", « Color », and deselect "Direct » and "Indirect".
Tip :
Leave the default margin value (16px). This margin will be a "security" distance that will overflow the color on the uvmap to not see the seams.



Image
  • Click on "Bake" (see the progress bar at the top of the Blender interface).
  • Return to the UV editor and save the new image.
  • In the Node Editor add another Image Texture node.
  • In this one, load the new image obtained.
  • Connect this node to your material output via a Diffuse BSDF.
Done!


Building the Atlas

You must first enable the "UV Texture Atlas" plugin in your user preferences:

Image

Once enabled and your user preferences saved:
  • Create a new empty image in the UV editor.
  • In the 3D view (or in the object tree), select the concerned meshes.
  • Select the "Render" tab and scroll to "Texture Atlas".
  • Create a new atlas with the "+" button. Leave the default name.
  • Select "No Unwrap", as you already have an UVmap.
  • Click on "StartManualUnwrap".
Image

A temporary object will be created and automatically selected.


- Still in the 3D view, switch to Edit mode for this new object.
- Select the entire mesh.
- In the UV editor, select UV→ Average Island Scale.
- Press Ctrl+P for automatic reorganization.

Note :
You may have to reorganize your different parts according to the complexity of the uvmap. Indeed during the baking operation, some colours could overflow on others.


Now let's go to the materials tab and create a new one relative to this new object, you can remove the others from the list.
  • Return to the "Render" tab and scroll down to "Bake".
  • Select the "Selected to Active" check box.
  • Select all your original objects by making sure you select the new object last.
  • In the Node Editor, add a new Image Texture node in which you will load the new UVmap.
  • Click on “Bake”.
  • Once the baking done, and still in the "Render" tab, go to Texture Atlas then click on "FinishManualUnwrap".
  • Save the new image.

Note :
In some cases, you may need to do some quick touch-ups with The GIMP (or any other image editor). But nothing too bad.
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

Post Reply