Per Pixel Lighting on iOS

Hi All

I've just purchased an iPad and built and run our concept game on the iPad. While I was hitting 30fps on 3G S the framerate crumbled on the iPad. I understand that this could be insurmountable as I am presuming that the fill limit is being hit because of the drastically increased screen size. Basically I have one directional light and one point light. Everything is set to diffuse fast bar one object which I have set to diffuse and one point light on the player set as important for per-pixel lighting. It feels like a simple setup, but it seems to be crippling performance - 30fps everywhere else, but when the one large object fills the screen I drop to 20fps. Scene is relatively low poly with 4.2K tris in view at the time I get 30 fps. I've reduced the entire scene to one material just to see if it is hammering to swap materials.

I've recently seen the Epic Citadel demo from Unreal, which I think is running native res, and probably massively simplified lighting, but they appear to be getting some nice per pixel effects with normal mapping, so I'm surprised that with just one object affected by per pixel lighting, that the performance drops so dramatically.

Is it worth me writing some simple shaders to improve performance?

Thanks Ian H

It looks like indeed you're fill-rate bound if there are too many pixels running with an expensive shader on the screen. I'd make some more experiments to confirm this and as a solution maybe try to simplify the lighting, use lightmaps or try to achieve the effect in a different way.

As far as I know Epic Citadel doesn't have any dynamic lights - it's lightmaps only. Because these are UE3-style lightmaps, you see some specular highlights. Also in the demo they avoid drawing anything that might consume the fill-rate excessively, so for instance there are no particles and almost no foliage and the demo is already running on the edge. Adding anything more to it (a dynamic light, a particle effect, an animated character) would also probably put the framerate under acceptable levels.

If you want to keep the same visuals as your game on the 3GS and dont mind the lower resolution, you can force your game to run in standard resolution on the iPad/iPhone4/iPod4G by setting Target Resolution to Standard in the Player settings in Unity before you build. This will keep your framerate acceptable at the expense of resolution and is what I do for the games that I require pixel lighting in (mostly for normal mapping).

Pay close attention to the size and compression settings on your textures too. I found by reducing texture sizes and acquiescing to using PVRTC compression as much as acceptable, significantly improved performance on ipad and iphone4 (ipad being the worst of the bunch, performance wise). Test this by setting all textures to the worst quality possible, PVRTC 2bit, 256x256 and see how it performs.

Drawcalls are apparently less of an issue than they were. Also look at baking in light, and occlusion culling.

Finally, can I recommend going into your xcode project application delegate and removing the 30fps limit when testing and always running your code with fps meter on, and then aim for >50fps on 3gs or iphone 4. I find I then get relatively acceptable performance on ipad. You generally don't want to go less than around 25fps (I consider this passable for very complex scenes, given that a Hollywood film does 24fps as standard)