Heli Merc: Fixing the slowdown E-mail
Sunday, 02 January 2011 08:58

One of the things that annoys me about some games is that they favour prettiness over performance.

I'd rather a responsive game, than a beautiful slug.

With this in mind, I've just spent even more time digging further into the performance issues. I realised that I'd need more information to figure this out, so I created a HUD that contains check boxes to control the graphics, and I made it accessible from a Menu button at the bottom of the screen. As before, I suspected that the main performance eaters were one or more of the background terrain model, the cloudy sky image, the flashing light effect for explosions or the shiny specular lighting effects.

With some proper testing under way, it quickly became apparent that the biggest performance killer was the background hills. Further investigation revealed that it was entirely due to the material used to render them, which had been set to receive both fog and dynamic lighting. Simply turning off these settings gave the game an instant 4fps boost. To sidestep this problem, I textured the hills to look like they were being obscured by fog, making them successively lighter the further they were from the camera. The shadows are simply be drawn onto these textures, avoiding the need for lighting.

The Sky texture was also a big issue, which I found somewhat surprising because the it wasn't large, only 128x64 pixels, and it's just a stretch, textured polygon that was parented to the camera to keep it in place. Just turning this off while the game was running gave me back 10fps, so doing the sky as a billboard was a really, really bad idea.

Shiva supports the ability to use a texture as a scene background, and when I'd first begun to investigate Android development, this feature hadn't worked. On the off chance that it had been fixed, I decided to get rid of the sky model and try the background texture again. Sure enough, it's functional now, and even better, it consumes half the frame rate of the textured polygon version, weighing in at around 4 frames per second.

The last two settings, the explosion point light source and specular lighting, seem to have little effect on the frame rate, consuming approximately 1 frame per second each.

Finally, with all four features turned on, the frame rate hovers around 29 frames per second, dropping to 26 fps with half a dozen enemies on screen, which is a big improvement, however, I'd still like to see it in a range of 28fps to 32fps once I finish the tweaks.

Out of interest, with all four features disabled, leaving just the enemies and foggy ground models active, the game runs at slightly over 40 frames per second.

blog comments powered by Disqus