Sprite packing is a very important thing, it not only enables you to save texture space (squeezing a 2048 * 2048 image of 128 * 128 px sprite grid into a single 1024 * 1024 texture means 4 times smaller texture on disk as file and in gpu memory).

But there's a another invisible enemy you beat at the same time in the rasterizer's "battlefield" which it's called alpha testing and can be a real speed issue on slow GPUs, it is basically a optimization step for the alpha blending, it discards fully transparent pixels before the alpha blending is performed (which is a even more expensive operation), but when you have a grid aligned texture of sprites of various sizes, in most cases because of some sprites that are larger but not neccesarily drawn most of time you have a lot of pixels that are blank but still occupy the graphics card pipeline.

So, packing these sprites tightly and only rendering the small area which is important saves a lot of pixels from wasting time in gpu pipeline, which gives older and weaker GPUs a lot more breathing space, see the picture on right as a comparison, the blue area was originally rendered althru a lot of pixels ended up being invisible, red is the new drawn rectangle which fits the actual actor sprite which is much smaller and optimal. So it's a double win for optimization this time. But there's always plenty of things left to optimize...

0 Comments:

Post a comment
Please post only comments concerning the blog post and stay on topic, otherwise your comment may be deleted.

Name:

Email (Not shown on website and not required, but enter it if you have a question and want the webmaster to respond to it)

Comment: