Multi UV texturing

More UVs, fewer textures.


Introduction

In certain cases we want our object to be reasonable detailed, we want to be able to change skins on it easily, and we don't have the resources to model and bake the textures from a highpoly object. We might also be short on memory where reusing textures is essential. In those cases one might want to use multiple UV sets and advanced shaders to add the necessary details in a memory and work efficient way.

(In this example I'll use modo 202 and Unreal 3, but I think the general idea is applicable for other software as well. I also assume that you have basic knowledge of both applications.)

Texturing steps

The first UV is for texturing the object with general, tilable textures. This gives the basic look of the final mesh. Although on the left you only see the unlit diffuse render, both the metal and wood textures have normal and specular maps as well.
The UV view shows that the vertices have coordinates scattered outside the normal 1,1 UV space, because these base textures tile.

The second UV is for ambient occlusion (baked in Modo). Here all the vertices are inside the 1,1 UV space. The red color indicates that poly UVs overlap. It is not a problem if the mesh is symmetric and will not receive a lightmap. (As in this case: this object is a part of a dynamic, moving machine.) If the mesh is not symmetric or we want it to have a lightmap later in Unreal, then we should get rid of all overlapping polys in this UV set.
The baked ambient occlusion is the only texture here which is object specific. Due to the nature of the map it should not be too big either.

The third UV set is for details, in this case rivets and bolts on the metal parts, but it could be anything from dirt patches on a window to creases on cloth. Only the texture's mapping is unique to this object, the texture itself is generic, and can be used elsewhere in different ways.
As you can see the texture has a few elements which tile vertically, like the column of rivets. Other parts of the texture are just stand alone pieces like that metal plate on the right.
I used the displacement channel of the detail map as a guide to set up the UVs, but there are 3 more related textures used.

I modeled the rivets and stuff in Modo, and then rendered 4 images of that scene, as you can see them on the left on the composite image.

The first strip shows the mask map, which defines where the rivets and bolts should appear over the base surface. The next one is the ambient occlusion, then comes the displacement map and finally the normalmap.

So we have the necessary textures, and the only thing left to do is to set up the shaders in Unreal.

Creating the shaders

The object uses a wood and a metal material. The wood is only affected by the wood texture and the ambient occlusion of the mesh, while the metal parts have the metal texture, the ambient occlusion and the rivets. First we make the base shaders which can recieve object specific data (the AO texture), then make a material instance constant and feed the actual texture into it. We will use the material instance on the mesh, not its' parent shader.

The base wood shader is pretty simple: the normal map connects to the normal channel, the specular to the specular, etc, as usual. The only difference to an average shader is that we have a texture parameter node which will recieve the object specific AO texture specified later in the material instance. We multiply the diffuse texture with this one before linking it to the diffuse channel. (Don't forget to set the texture parameter's UV coordinates to "1" so it uses our second UV set.)
When it's done, we make a material instance, and set the base wood shader as parent. We set the proper object specific AO texture, and apply it onto the mesh.

The base metal shader is a bit more complicated. The basic principle remains the same, only this time we start using the textures of the rivets. There are many solutions possible. I used the mask texture to show a lighter metal texture for the rivets. AO is set up the same way as in the base wood shader. (Although it's not really visible on the dark metal heh. :) The displacement map can be used as displacement but also to show worn surfaces: the more something sticks out the more fray it will collect.

<-- And this is the result.

Although setting up the shaders can be time consuming, it needs to be done only once, and then the material instances take care of the rest. We can easily replace the wood to stone, the iron to brass, the bright gray rivets to dark red wood dowels, just by replacing texture names in the material instance.