/texture-atlas-generator

Texture Atlas Generator/Packer written in Java using a single source file.

Primary LanguageJava

Texture Atlas Generator

A texture atlas generator/packer written in one single Java file. Currently it only supports loading and saving of PNG textures, this can easily be extended to other formats supported by Java’s ImageIO class.

Besides the texture atlas, a .txt file is also generated with texture coords for all the textures.

Examples and further details are available at my website

The texture packing algorithm used in the atlas generator is the Lightmap Packing Algorithm by Black Pawn. The images are added to the atlas by area size (width x height), in descending order.

The source code for this application is released into the Public Domain.

Building

javac AtlasGenerator.java

Usage

AtlasGenerator <name> <width> <height> <directory>

Example

AtlasGenerator atlas 2048 2048 images

This will take all the PNG files in the images directory next to application and pack them into one or more 2048×2048 atlases named “atlas1.png” to “atlasN.png”, where N is the number of atlases generated. More than one atlas is generated if the PNG textures do not fit into one atlas.