optimize game for iPhone 4

Hi there, i’m in the final of developing a game for the iPhone.

Until now, I had a iPhone 3GS and 4S to test and it runs well on both.

But today, I tried it on someone’s iPhone 4 and get like 5 FPS. It’s as slow as the 3GS and has the high resolution of the iPhone 4S and now I have a problem.

What do you think are the best way to optimize for the iPhone 4?

my game relies heavily on pixel lights in combination with very few models (only planes and spheres, but normal mapped and a lots transparent shaders). I use up to 3 lights simultaneously and it works fine on the 4S because it’s fast and the 3GS because the resolution is low.

any ideas?

Is there a way to force the resolution on the iPhone 4 to be the same as on the 3GS? (one quarter) this would be a quick and dirty solution… but i guess, customers won’t be happy having no retina-graphics on the iPhone 4.

Any other ideas?

What is the general way of making a game on the iPhone 4 look as good as on the iPhone 3GS even when it has to render 4x the resolution but isn’t 4 times as fast?

In my experience the most taxing thing for the iPhone 4 is having a lot of materials with shaders that use per pixel calculations, diffuse and transparent shaders for example. So where you can replace these textures with vertex-lit ones, if you only have directional lights in your scene (you’ll get the best performance on iOS with a single directional light) you can use the the “Mobile/VertexLit(Only Directional Lights)” shader, otherwise use “Mobile/VertexLit”. If you can replace your per pixel shaders with these where ever you can you’ll see a large performance jump, especially if you are changing the shader on objects that take up a large amount of screen real estate.

You can read some more about this topic at http://unity3d.com/support/documentation/Manual/Optimizing%20Graphics%20Performance.html.

Good luck!

I made a plugin in obj-c which tells me which device it’s running on, then I changed textures, etc, where necessary. Let me know if you’d like the code for the plugin.