Thursday, 16 March 2017

Python tool : create texture atlas

This is the python tool I made to create texture atlas using python.

It is normal to pack multiple textures into one to reduce the draw calls. 

To avoid doing copy and paste the images one by one in photoshop, I wrote a python tool to do it by one click.

This tool is written in Python 2.7 and PIL. It pack all images of the same size into one atlas. As a result, you will have multiple image atlas in a new created "out" folder that locates in the same folder as the original images. The number of image atlas depends on how many different sizes you have for the original images. 

Here's how you use this tool:

Prepare: 
The tool will need python 2.x version and PIL package installed.
Copy the folder [createArrays] and file [runCreateArrays.bat] into the image folder

To run the tool:
1.double click    runCreateArrays.bat 
2.enter CreateArrays.py in the command line tool


About the tool:
By default, create Texture atlars for same size images that are located in the same folder
with [createArrays] and [runCreateArrays.bat]. 

But you can also target another image folder by using   
CreateArrays.py -sp
In this case, the tool will allow you input the absolute path for the target image folder.
To be notice, if the default image folder does not contain any image files, you have to specify
a valid folder to conitue.
By default the output name will be OutputName_size.extension. You can change the name by using
CreateArrays.py -o imageName

The output files will be located in a [out] folder that is created in the target image folder.

Thank you!


you can download the tool here 

No comments:

Post a Comment