Pack multiple texture types with same layout

Joachim Grill
Last updated:

Objective

If additional texture types (e.g. for normals, reflection, ambient occlusion) are used, they must be packed with the same layout as the "main" sprite sheet containing the albedo.

Problem

TexturePacker supports only one additional texture type for normal maps. It can be enabled in the "Advanced settings", see "Normal maps: Pack with same layout".

Solution

The following workaround explains how to use the TexturePacker command-line client to pack more than one additional texture with the same layout.

Let's consider the following example:

input sprites

For each sprite there is a corresponding normals and ao image in the corresponding subdirectory.

Step 1

Create a TexturePacker project and add the sprites to it, but do not add the normals / ao images. Save the project as .tps file, in our example we call it capguy.tps. Update this file if you have to add/rename/remove sprites in your game.

sprite sheet

Step 2

With the TexturePacker command-line client we can load the .tps file from Step 1 and reconfigure it. We use the following command-line arguments for that:

ArgumentDescription
capguy.tpsthe TexturePacker project to load
capguy/normalsadd all image files from "capguy/normals/" directory to the project
--normalmap-filter normals/used as search string in the image file path to identify the normals
--normalmap-sheet capguy_n.pngthe name of the generated normal map texture

For each additional sheet TexturePacker has to be called once with adapted parameters:

TexturePacker capguy.tps capguy/normals --normalmap-filter normals/ --normalmap-sheet capguy_n.png
TexturePacker capguy.tps capguy/ao      --normalmap-filter ao/      --normalmap-sheet capguy_ao.png
normalmap
ao map

Texture background

Since this feature is designed to pack normal maps, the empty parts of a sheet are filled with the light blue normalmap background color. Use the following command-line parameter to set another background color:

ArgumentDescription
--background-color ffffffbackground color as hex value (RRGGBB)

The alpha channel of the texture background is set to 255 (solid) if all packed normals images are solid. If there is at least one input image with transparency, the background of the output texture gets transparent.