Tim Mensch

2 minute read

One of the ways I’ve learned to improve performance of a game is to reduce use of video memory through the use of texture atlases. A “texture” in a game, in this context, is a bit of graphics that will be drawn to the screen as part of the game.

A texture atlas is a set of textures that have been cropped to the size of the actual image I need in the game – when image files come from the artist, they usually contain a great deal of blank space around the image, and those blank pixels take up valuable video RAM, which can slow down the frame rate during game play.

But an atlas contains a lot of images, and sometimes those images aren’t being used at the same time. Loading the entire atlas at once uses more video RAM than loading only the separate, uncropped images needed for a particular frame of rendering, but if you have enough video RAM to hold the entire atlas of images, things will go faster.

It turns out that on some of the older phones, there’s not enough video RAM to hold all of the animation frames I need for Hamster: Attack!, and so this alleged optimization made things worse. As in 2-3 frames per second.

So instead of a few huge atlas files, I had to break things out into much smaller atlas files, to prevent frames that aren’t being used at the same time from all being loaded into video RAM. This brings the frame rate back up, and as predicted, it’s now faster than it was before – it can now draw at 50 frames per second, whereas before I started this experiment I wasn’t seeing better than 20FPS. Much better.

comments powered by Disqus