Blog

AtlasMaker 0.7 – Make Texture Atlases in Photoshop

November 24, 2012 63 Comments

August 2016 Update: AtlasMaker is now on Github: https://github.com/richardjdare/Atlasmaker

In game development it is common to have hundreds if not thousands of texture maps and animation frames in a single project. Keeping track of all these images is taxing for both the developer and the computer, so what we do is arrange the images into texture atlases.

A texture atlas is an image that contains many other images. Usually, all the animation frames for a single sprite, or all the textures for a single object are arranged into a single image. The game code then looks at a smaller portion of this image when it needs to draw a particular sprite or texture.

AtlasMaker is a Photoshop script that lets you create these atlases inside Photoshop. It takes a directory of individual textures and arranges them on a single image. It can be used both for atlases of different sized images, and for tile grids which are commonly used in 2d games. Earlier versions of this script were released in 2009. I know I promised an update long ago, but I have been working on my iPhone game, Toxin. I have been using this script throughout Toxin’s development, but never got round to tidying it up for public release.


AtlasMaker main window. A tile grid for a 2d game is being created

Features

  • Cross platform – tested in Photoshop CS3,CS4,CS5 on Windows and Mac OSX.
  • Open Source
  • Create texture atlases or tile grids for 2d games.
  • Several image sorting algorithms. Find the most efficient one for your textures.
  • Add a margin to each image.
  • Custom data file export.
  • Extendable – It’s easy to add your own rectangle packing algorithms and sorting methods.


Generated with AtlasMaker: Left, a texture atlas with variable sized images. Right, a tile grid. Images used are randomly generated test textures.

Installing AtlasMaker

There are two ways to running AtlasMaker in Photoshop.
Unzip atlasmaker-v0.7.zip to your photoshop scripts folder. On windows this is usually: C:\Program Files\Adobe\yourphotoshopversion \Presets\Scripts
On a Mac this folder is at: Applications/yourphotoshopversion/Presets/Scripts

When you next start Photoshop, AtlasMaker should appear in the File->Scripts menu.

Alternatively, you can run the script without installing by unzipping the atlasmaker folder somewhere, then selecting Scripts->Browse from the file menu and then selecting AtlasMaker.jsx.

Quickstart guide

The first thing to do is select a directory of images by clicking “browse” at the top of the window. Once you have done this, AtlasMaker will scan through the images and collect size information about them.

Next, you want to select your packing method. If your images are texture maps of different sizes then you want to select the “Atlas Maker”. If you are making a traditional 2d game where the sprites are all the same size, then you want to select the “Tile Grid”

You’ll notice that some text will appear underneath “Number of Files”. This is a notification from the Tile Grid Packer telling you how many rows and columns your images will take up given the default document size. Different packing methods provide different notification messages according to their nature.

Then you can optionally select a sorting method. Sorting the images in different ways can improve the efficiency of the texture atlas. Some packing methods do not allow sorting, and will disable this option if they are selected.

You can also add a margin here if you want a gap between your textures. Margins are added on to the width and height of each image just like CSS margins.
Next, click “Document Settings” and you will be able to set the size of the texture atlas you are going to create. You can also set the document name here, and choose if you want to flatten all the layers into one, once the atlas is complete.

Now click “Create Atlas” and you’re done.

Custom data file export

One of AtlasMaker’s most powerful features is the custom data file export. You can export a text file for each texture atlas containing information about each image on the atlas. This might be XML or JSON to be loaded by a game engine, or you could use it to directly generate source code to be pasted into your application.


AtlasMaker custom data file panel. Here an XML fragment will be generated for each texture in the atlas. filenames and texture positions are substituted into the text using tags

Tags are used to substitute information about each image into the text:

  • #i – Image index (0.. number of images in directory)
  • #filename – Filename of source image
  • #width – image width
  • #height – image height
  • #x – X position of top left corner on atlas
  • #y – Y position of top left corner on atlas
  • #p – page number

If you click the “Reorder export file” button, you can rearrange the order in which textures are listed in the export file. Just select filenames from the list and click “up” or “down” to reorder them. You can select multiple filenames by shift-clicking.

The zip file contains a readme.txt which describes every option in detail.

AtlasMaker is designed to be extensible. It is easy to add new packing methods and sorting algorithms. I have written the code to be more or less self explanatory in this regard, but if you want me to write something about it, please let me know.  And let me know if you find any bugs!

Download the latest version of AtlasMaker from Github

Download from Github

View Comments

Toxin – Creating sprites in Processing

November 18, 2012 0 Comments

One of the most powerful graphical tools I am using to make Toxin is Processing, a Java based platform used to create generative art. Processing provides you with a basic IDE, a graphics API and a simplified front end to Java that lets you get things up and running with a minimal amount of work. It’s great for doing experiments or when you need to create art programmatically rather than with a graphics program.


Processing provides a simplified front end to Java, ideal for quick experiments

The green cells in Toxin were all generated using a Processing program. Each cell is a circle made up of a number of connected spline segments. I animate the cell by displacing the spline control points using Perlin noise. The cells are then resized and colourized in Photoshop.


Left, a cell being rendered in Processing. Right, the finished result

As you can see, the finished product does not look exactly like the original Processing output. I had to do a lot of tweaking, re-rendering and reprocessing until I got them looking right. It was very time consuming. There were many moments where I wondered if I was going to get useable results at all.

Many of Toxin’s graphical effects have their origins in experiments I did with Photoshop blend modes. I discovered that certain combinations of layers and modes resulted in nice abstract animations when the layers were dragged around. I wrote photoshop scripts to perform these movements and spit out animation frames. Unfortunately these scripts revealed many bugs and inaccuracies in Photoshop and its scripting system. You only have to look through the source of my AtlasMaker Photoshop script to see how many strange workarounds are required to accomplish straightforward tasks.

To solve these problems I implemented Photoshop’s blending modes in Processing, and use this to create my animations. Below are a few frames from Toxin’s shot animation that demonstrate the technique. The way the colours shift throughout the animation is down to the movement of multiple layers blended into a simple white shot sprite. You can get a better idea of how this looks in the game by looking at the screenshots I posted a couple of weeks ago.


Many of Toxin’s sprites use animated image processing effects


I also used Processing as a test bed to work out algorithms before implementing them in the game. For example, Toxin has a weapon which freezes the edges of groups of cells. It didn’t take long to prototype this in Processing.


Testing a powerup that uses a flood fill algorithm to find edge cells

Stay tuned for more posts on Toxin, and a new version of my texture atlas Photoshop script which is in final testing…

View Comments

Games and the Imagination – now on PDF

November 11, 2012 0 Comments

I’ve added a pdf version of my 2004 article series Games and the Imagination to the writing page. I still get people asking for it in an easy to read format and I found that since their last redesign, the layout of Gamedev’s article section doesn’t do much to reflect the amount of work that goes into such writing. It looks a little like some lost blog post that got picked up by a content aggregator or something, so I made the PDF to provide a better reading experience.

In Games and the Imagination I use Jungian psychology to explore how players imaginatively engage with games. Its main idea is that gamers do not simply identify with playable characters but that the whole game can operate as a kind of dreamscape where all characters, landscapes and situations have the potential to reflect the gamer’s psychological concerns.

When it was published on Gamedev in 2004 I got a terrific response; people wanted to cite my work in their studies, I had several working psychologists respond positively, and even a few big names in the games industry wrote to me.

I come from a self-taught working class background; university wasn’t even mentioned to me when I was at school, so it was very gratifying to have students and big-shots thank me for helping them with their studies and asking to cite my work.

I left school in a bad way, depressed and angry; angry at bullying, angry that nothing in my world appeared to allow me to be the person that I felt I was, a creative thinker. The responses I got from my writing really made me feel that the years of lonely self-education that followed were finally leading to something.

The one thing I didn’t get out of it was the one thing I was desperate for: a job in the games industry. I actually wrote the series some time earlier, and was using it as part of a portfolio of code that I was sending out with job applications. I’m not sure how many of the people I sent it to actually read it. I probably didn’t push it hard enough. A part of me has always wanted someone else to come over and say, “Hey, you belong over here, come and join us”, but that never happens.

New Ideas

After I finished Games and the Imagination I got interested in the idea that there might be a single language of game design, a grammar or logical system that could be used to describe all games. I wrote a little about this in part four and linked it with ideas that went back to my first game design article from 2001.

A lot of work has been done in this area in the past ten years. People like Raph Koster, Daniel Cook, Ernest Adams and Joris Dormans have done detailed analyses of game mechanisms in the hope of eventually deriving something like a grammar or set of logical axioms that designers can use to think about how games work.

My own approach is more phenomenological. After surveying the usual suspects such as semiotics and system theory, I started reading twentieth-century philosophy; Wittgenstein, Husserl, Heidegger and Deleuze, to name a few important figures. I’ve spent probably six or seven years on this study and I still don’t feel that I’m ready to write anything yet.

I *do* have concrete ideas, and they are informing everything I do when I work on my games, but I just don’t feel capable of describing them in words yet. I have a picture in my mind of a nicely illustrated book, but I’ll probably just end up with a simple pamphlet stating the obvious! The ideas I have in mind are simple, Its just that they are not made of the same stuff as ordinary concepts if you can catch my drift. They are about appearance, not representation. (Told you I wasn’t ready to write yet:) )

Another area that I got interested in was the investigation of the imagination itself. What does it mean to imagine? Why does this faculty seem to be treated so dismissively outside of a few subcultures? How does it relate to other faculties? Can a rethinking of the place of the imagination within phenomena tell us anything new about being human, or open up new horizons for us? These are some of the questions that come to mind. I plan to write some more about these questions soon.

View Comments

Toxin Graphics – Introduction

November 3, 2012 0 Comments

It has taken me a long time and a lot of experimentation to get the graphics right for Toxin. When I began, I didn’t really have a single picture in mind of how the game was going to look. I knew I wanted abstract, and I knew I wanted a contemporary style influenced by information graphics and designers like James White, but that was all. Most of my inner images of the game were fleeting. I had a gameplay concept and a “feel” in mind more than anything else.

Also, Toxin is the first game I have worked on since the Smartphone stuff I did around 2002-2003. I was desperate to get back into game development and I mistakenly thought I could begin again where I left off. It was like running into a brick wall. The first artwork I did was so bad I deleted everything, took the bus into Stratford on Avon and spent the rest of the day sitting by the side of the river in despair!

It took me some time to reach my old level again and then improve on it. As much as I have enjoyed developing Toxin and the creative discoveries I have made, there has been a great deal of struggle and fruitless experimentation involved.

The interior designer and UK TV legend Laurence Llewelyn-Bowen was an unlikely influence. On his TV home makeover shows he’d get his clients to collect images they liked and pin them to a board for inspiration. I had a Toxin folder on my laptop which I filled with images from ffffound and other design inspiration sites. When I got stuck I’d fire up IrfanView and spend half an hour blanky staring at images until some ideas popped up. I highly recommend this practice. A few of the images from my Toxin folder are in the image below.

Toxin Image Board

That watch is a Dievas Aqualuna Blue Professional. No I can’t afford one yet. Buy Toxin!


Toxin Ship SpriteThe first thing I did was the main ship, which is the only thing I got right first time; it remained unchanged throughout development whereas everything else got remade at least three times! I think it works really well and has a nicely balanced, iconic look. I designed it in a vector drawing package which I later abandoned in favour of using rendered, animated splines created in a 3d program.

The background was next. It was essential to get the background style nailed as it would define the look of the whole game. I tried a few different styles as you can see in the rough drafts below.

toxin background drafts

One of my biggest goals here was to create something that looked good within the phone. Too often, mobile games just present windows on to the game world without any consideration for the device that is running the game. To me this is like designing a watch face without taking the case into account.

Next time I’ll talk about how Toxin uses procedural graphics and describe how I used Photoshop scripting and Processing, a Java based generative arts platform to create much of the game’s artwork.

View Comments