Payback 2 Logo

Next Gen Graphics Engine

/ 19 May 2015



Introduction

Mobile graphics chips have progressed a huge amount since Payback 2 first launched, so we felt it was time to completely overhaul the game's visuals.

This Dev Diary goes behind the scenes on the huge changes that were made in the latest update (v2.88). We've posted some screenshots of the new update to the media page.

New Graphics Engine

The biggest change was that we completely rewrote the graphics engine to better support the latest hardware. This allowed us to include features such as normal and specular mapping, which allow the fine details of a surface to catch the light in a realistic way, rather than appearing dull and flat.

The game also now does real time specular and diffuse lighting for all lights, and calculates lighting caused by the sky and the reflected environment.

The water is also significantly improved - where before it was just an animated texture, now every tiny wave reflects the lights and environment in a realistic way:

Old New

We've also added a subtle haze - it's not something you usually consciously notice, but it helps to add a bit more realism to the scene. Anisotropic filtering is now supported on high end devices - this makes the textures sharper when viewed at an angle.

We also now simulate dirt on the camera and internal reflections inside the lens that cause artifacts when there's a bright light such as an explosion.

Last but not least, all the objects (vehicles, people, trees, etc.) are now lit properly by the lights in the scene, rather than just being tinted.

New Textures

The game's original textures go all the way back to the Amiga days, so there they were very low res - only 64x64 pixels. In addition, they were originally designed around a fixed 256 colour palette, so they have dithering and banding artifacts, which looks particularly bad when scaled up to modern resolutions.

The game now uses up to 512x512 textures, which are all of course 32 bit (16.8 million colours, plus an 8 bit alpha channel for transparency). Here's a comparison of the old and new versions of the same texture cropped and scaled to the same size:

Old New

As you can see, the difference is huge!

It's also worth mentioning the new textures also include normal and specular maps. These allow the real time lighting to properly shade the bumps and different surfaces of the texture, which is not shown in the image above.

Scalability

One big challenge in this update was pushing the boundaries on the latest devices, whilst also making sure the game still ran well on older hardware. A key approach we used was to dynamically change the resolution in order to maintain a constant framerate. This has a number of advantages:

  • Drops in framerate and generally more noticeable than drops in resolution.
  • Due to the complex pixel shaders the game now uses, even a small reduction in resolution significantly improves performance, so this helps the game scale across devices.

We also use simpler shaders on low end hardware, and target either 30 or 60 fps depending on device performance. The game also includes 64 bit support on iOS, which allows it to use the faster instruction set of the latest devices.

As a result of all of this, the game is able to fully utilise everything from an iPhone 4 to an iPad Air 2 - roughly a 100 fold difference in GPU performance!

Fitting It All In

Due to the increased texture resolution and the addition of specular and normal maps, the game now has 32 times more texture data than it did before. As a result, the game grew to well over 200MB in size - much more than the 100MB limit for cellular downloads - so there was clearly work to be done.

We wrote a custom compressor for the specular and normal maps which was able to make them around 12 times smaller without noticeably degrading the quality. We also reworked the way textures were stored to avoid duplicates in certain situations.

Another major improvement was rewriting the speech compression to reduce the size of the speech by a factor of 4, whilst also increasing the sound quality from 22KHz to 48KHz.

All of this extra compression could potentially cause longer load times, so we worked hard to streamline this. We managed to optimise the decompression algorithms to be twice as fast, and also added multithreading support. In addition, the loading and decompression is now done in the background whenever possible.

As a result of all these changes the final download is only 90MB in size, which is only slightly larger than the previous version. Initial loading times are generally the same or better than they were previously. Inter-level loading times are dramatically faster - usually virtually instant.

Conclusion

As you can see, this is a huge update. We hope you enjoy it!

James Daniels
james.daniels@apex-designs.net
(PS: Please don't forget to join our mailing list!)