This is a guide to help you combine or split a combination of texture maps. Specifically here we will combine a color and roughness map for use with Unity. You could modify this example for any similar purpose.
You may skip to the last step “Render!” by downloading the template and skipping the explanation.
This result could be achieved in image editing software, however as someone who has experience in Blender and relatively little in photo editing software I find the node based set up of Blender’s compositor more intuitive & flexible. It’s also more seamless when already working on the textures inside Blender.
Firstly we must understand what a material does, a material contains a program (the shader) and a number of inputs specified by the shader. The shader defines how light interacts with a surface, and the inputs can be numbers or textures representing specific details of the surface.
Unity’s default shader uses one texture input to define the color of the object as well as it’s smoothness. Color is comprised of 3 channels, red, green, and blue. Smoothness is only a single channel, describing how smooth the surface is. The total is 4 channels which can be combined into a single RGBA texture for efficiency, this is what Unity does.
So, the problem is you have 2 files, a color map and a smoothness map, but Unity accepts only one combined texture. The color map is also known as diffuse or albedo map, and you may have a roughness map which is simply the inverse of smoothness. This guide shows you how to merge the two into a single “Albedo/Smoothness” texture for Unity.
Blender will open the 3D viewport by default, we don’t need this, switch to the compositor like shown.
Enable “use nodes” to turn on the compositor.
When we save the result blender will Embed a color profile, this is defined in the properties window in the “Render Properties” tab, at the bottom under “Color Management“.
sRGB is the standard for color maps like we’re looking at here, if you are working on other data like normal maps we would need to change this. Set “View Transform” to “Standard” and leave “Look” on “None“. While we are here, under “Sampling” adjust “Render” to 1 to speed up the unnecessary scene render later.
We will be reproducing the node setup shown here.
To add a new node to the graph move your mouse somewhere on the graph and press Shift+A, we want 2 Input→Image nodes. Place them one above the other, and add a Converter→Separate RGBA node to the right of the top file node. If you have a “roughness map” instead of a “smoothness map” and want to use it in Unity we need to invert it, do that by adding a Converter→Math node next to the lower file node. Setting the math node to subtract and the top value to one will invert the roughness map when plugged into the second value (1 – roughness = smoothness). Add a Converter→Combine RGBA node and a Converter→Alpha Convert node to the right. The alpha convert node defines how the alpha is handled by Bender. In this case it means the color texture we provided looks as it would if it was entirely opaque as oppose to how it would had the background color become visible through the transparent sections, we want this because we’re not actually using the alpha channel as transparency. All that’s important here is to set it to “Straight to Premultiplied“. Remove the default “Render Layers” node and link them all up as shown.
On the top file node press the folder icon and load your color map there. Do the same with the lower file node and your roughness/smoothness map. If you have a roughness map and you want a smoothness map (Unity wants smoothness) leave the subtract node as it is, or else remove it from the chain.
For the lower file node only, the roughness/smoothness file node, set the color space to linear as this is not color data. Forgetting this will make your smoothness map too glossy in Unity.
Press F12 (or Render→Render Image) and Blender will render the scene, let it finish and then your new texture map will appear! Hit Image->Save As. Leave on “Save as Render” to apply the color profile we specified earlier. Place the generated image into Unity and drag it into the “Albedo” slot on your material as normal.
The compositor does post processing work on a rendered image. By swapping out that render result to images we already have we can use the compositor to operate on those images. Blender expects that you are rendering a scene and operating on the render result, so even though we are not doing that we will run the compositor by pressing “Render“. That’s why we set the samples to 1, it’ll speed up that part we’re not worried about here.