Texture Channel Packer Utility

Here is a single class utility that can be used to pack textures together. Its helpful for optimizing and reducing the total number of texture reads for any materials that use many texture maps.

It can be used to pack any color channel from one texture to another, but it also has two convenience methods so you can easily pack Normal-Parallax as well as Metallic-Roughness maps

Normal-Parallax Map

  • Normal map packed into RGB channels
  • Parallax map packed to Alpha

Currently, JME’s stock phong and PBR shaders both allow for the usage of a packed normal parallax map.

Metallic-Roughness Map

  • Ambient Occlusion map packed to Red
  • Roughness map packed into the Green
  • Metallic map packed into the Blue
  • Emissive Intensity map packed to Alpha

Currently, the stock PBR shader only uses the Green and Blue channels for determining the Roughnes and Metallic values respectively. Custom shaders may vary


Here’s some example code showing how you can quickly use the texture packer to pack a Normal-Parallax map

    //change this to match your project's asset directory!      
String assetDirectory = System.getProperty("user.home") + "\\Desktop\\JME_Projects\\TheAfflictedForests\\assets";

     //create a new TexturePacker object 
TextureChannelPacker texturePacker = new TextureChannelPacker(app, assetDirectory);

     //load textures
Texture normalMap =  app.getAssetManager().loadTexture("Textures/");
Texture parallaxMap = app.getAssetManager().loadTexture("Textures/");

    //pack texture!
try {
    String newTexSavePath = "/Textures/packedNormalParallaxTextures/packedNormalParallaxTexture.png";
    Texture packedNormalParallaxTexture = texturePacker.packNormalParallaxMap(normalMap, parallaxMap, filePath , ColorSpace.Linear, null);
} catch (IOException ex) {

I am also wondering if it would be a good addition to the SDK if I were to add a button into the Material editor interface, so the user could conveniently pack the selected material’s current textures into a normal-parallax or metallic-roughness map with a single click.
@Darkchaos do you think this could be an acceptable addition to the SDK’s material editor ?


Yes this would be an acceptable solution, there are just two things to figure out:

  1. While it defeats the purpose of being a Single-File Utility, some repo/maven coords would be nice to have a reliable source and to get updates somehow. Like if I was to copy and paste this file, changes will never make it to the sdk
  2. We have to think about the UI however. How would we make such a thing accessible to the user? Does JME support both, unpacked and packed and thus one could just click a magic button and it is swapped? If so, we have to think about the name for the new texture file, how do we do that?