Multiple Baked Textures Shared in a Single Image.

I have recently been developing a Cycles tile material with a view to be able to use it in multiple projects. I wanted variation in the individual tiles location and rotation, and have also included a new/old feature which adds additional bump and spec masks. After much experimentation, I decided to have a separate .blend for modelling a single tile, coupled to an array modifier, which when applied allows me to quickly add variety to the tiles. I then bake out the AO, displacement and normals to individual image files which I can plug in to the tile material along with other dirt textures, etc.
I know it sounds a bit long winded, but its very quick to create new tiles, with grouting and variety, and the resulting bake textures can be very high quality. With some creative mapping and editing you can create vast numbers of pseudo random tiles on a single faced plane with excellent results from only a few modelled tiles.

All normal so far. The thing is that I realised that a lot of the information encoded in the bakes could be shared. Both the AO and displacement textures, for example are greyscale, so I did this in the compositor:

As you can see it just adds the baked AO texture image and the baked displacement texture on the red and green channels respectively. The difference node shows that there is no difference between the original and the channel compressed images.
Then, in the material compositor, you can separate them thusly:

Here, the displacement texture is separated out and plugged in to a bump node alongside the original, the gradient texture just applies the new texture on the left hand side, and the original on the right. In this quick viewport image, you can see there is no difference, and the join is seamless.

The AO can be separated in a similar way, on the red channel. A third greyscale texture could also be incorporated, in the green channel, saving even more data. In my test of 4k textures, 100% compressed 16bit .png files, the two originals were 16.5 and 16.1Mb, the colour channel image was 20.1Mb, a saving of 12.5Mb, or almost 1/3 (unsurprisingly!) without loss of data. Some baked textures with the same 4k resolution can be much bigger, and so the saving is also bigger.

I thought I would share this little tip with the community, I don’t know if it’s widely used, or used at all, and I welcome any thoughts or comments, technical or otherwise about this technique.

I’ve heard it’s used in videogame texturing a lot. sometimes, with widely different textures plugged into each channel.

Hi @zzero101,

Thks a lot for this very good tip for Cycle! But when Therahedwig, you say in videogame, you don’t think to Blender because you need the nodes compositor, isn’t it?

How to make the same thing with the BGE and python scripting, please? Is it the good way?

Wow! This is a lovely trick thanks for sharing.


Also this is worth checking