i am trying to optimize my game for quite some time now and i am running low on ideas. it works great on my mac but on the iphone i get ~26 fps maximum.
here are things i did so far:
i have 13 draw calls, 13 batched ones (i used a texture map for most of my objects).
tris: 272, verts 552
used textures: 10 - 11.6 mb
my scene has 1 light and 2 cameras (one for gui and one for the scene).
also i did set kfps to 60 and kAccelerometerFrequency to 10
#define FALLBACK_LOOP_TYPE THREAD_BASED_LOOP is activated…
my textures are compressed with RGB PVRTC 2 bits.
all this should be good for performance according to guides and lots of blogs… but it isn’t. does anyone have any idea why i still don’t get better framerates with this project?
i did that of course and i see no memory leaks or stuff like that. memory is low and stable, triangles and draw calls are low and all scripts use about 1-5% cpu.
edit: i get the feeling that the physic stuff is the limit. i am a bit confused about the settings in the time manager. maybe they are working against me…
the profiler is currently crashing for me on ios5. i used a script someone offered me on irc ( Code Optimization in Unity : Part 2 | robotduck ) and it told me that all my scripts need around 1% cpu.
thats why i get the feeling that my physic settings or my time manager are not up to their game. but i am not sure how to improve it
Just a thought - check the two cameras to see if you’re double rendering the scene. I had that happen on one of my projects and I think I had to do a full camera disable/enable when switching between the two. Also be careful with projected lights and shadows… particularly if your geometry is not sectioned up into pieces as it has to redraw whatever it is casting on. I usually stick to a single directional light in the scene and then do everything through textures and bake everything static. Moving objects you have to get creative with and choose a shadow option that works for your scene and produces adequate performance. In order to get framerates up on one game I literally had to explode the meshes in Maya into individual polygons to get 5 shadow blobs to perform adequately.
After re-reading, it seems like you probably are double rendering on purpose. Can you include your GUI on just one camera instead of two separate camera instances? I’d at least explore this…
as for the 2 cameras: i will try that but i am afraid that this will not change much. what i read so far is, that if you use 2 cameras the worst case would be that you have twice the draw cycles. and well… i don’t have many of them.
shadows i don’t use at all and i only have one directional light.
how can i make sure i “bake static”? not sure what that means.
I was once in the exact same position as you. I tried to use a paralax effect with 2 different cameras, but the game ran really bad on the iPhone when I did this. After hours of experimenting I found the solution for me. I simply disabled Vsync in the quality settings. After that the game ran smoothly with 60 fps on the editor as well as the iPhone.
i did set USE_OPENGLES20_IF_AVAILABLE to 0 instead of 1 in xcode and suddenly it runs smoothly with 60fps. looks like opengl 2 wanted to do funky business with my graphics.
Haha! After reading your post I just made this change too and went from a troublesome 12fps right up to 30-32!! Made my day!
For me it seems the change may have started after I began using the CheapForcefield shader from the forums. I think I’m now going to just pre-render my jewels as a sprite sheet instead of using 3d models…