When trying to optimize your sprite engine and reduce the time needed to draw a frame, optimizing texture size and texture batching are all well and good but they won’t do much good if you’re simply trying to draw too many sprites at once. In order to maximize performance, it’s important to be able to quickly determine which sets of game objects actually need to be updated or drawn on any given frame. With a large, heavily-populated game world, only submitting to the GPU objects that will actually be on the screen can reap enormous performance gains.
One of the most common methods to determine which objects occupy a particular area of the game world is to implement a spatial index. There are many different algorithms that can be used to implement a spatial index, but in this post I’ll cover one of the simplest: a Grid index.
Continue reading