During the first year at TGA everyone made three 2D games. These were made in the 2D game engine provided by the school - TGA2D. A big problem that quickly arose was reducing the amount of draw calls, which was eating a big portion of the frame time. A natural solution was batching sprites, so efforts were made to create texture atlases. This took time from both the graphic students who had to create the atlases, and then the programmers who had to manually calculate the different areas of the atlas and the corresponding UV coordinates, and finally map that in code. Furthermore, it was very rigid and cumbersome to update existing atlases once they were made.
Introduction and problem overview
A part of the generated json file
Integrating it in to our game
Finally, to make everything completely automatic and save time for the programmers as well, I wrote a wrapper for the sprite class in TGA2D, which made the user completely unaware of the fact that sprites were being batched and put on an atlas. The programmer no longer had to manually enter texture coordinates for the sprites on the atlas, which were transformed to the original UV-space of (0,1). Furthermore, the interface was made in such a way that if a sprite was to be used that was not on the atlas, the user didn't need to change anything, the interface was the same. Most importantly, everything was updated automatically once a new atlas was created.
During the last project of the first year, I extended this system to also create a corresponding atlas for normal maps for sprites who had a normal map. It then added that normal map automatically (but could of course be turned off) to the sprites who had one.
Atlas for normal maps