- Home /
Why does my game require so much rendering power?
Hey everyone. I made an android game in Unity over the past 3 months and for the past week I've been trying to optimize everything to get the game to run at a decent fps. I fixed up all of my scripts, but I still have bad fps. When I check the profiler Unity says my game is using 63% on Device.present under Graphics.PresentAndSync. 43ms!(http://puu.sh/5Xkoa.png this pic is of the profile analyzing the game running on my galaxy tab 10.1) I've searched and searched but nothing seems to help. I'm pretty much a beginner with Unity and game making in general so I'm left clueless.
Here's what I've tried doing:
Changing the opengl version (no effect)
I've changed all my shaders to mobile shaders
Changed all of my textures to their lowest settings while still being able to keep them looking nice.
I've put mostly everything into a texture atlas.
More pics: The title scene http://puu.sh/5XkPd.jpg
The title scene with stats displayed http://puu.sh/5XkKd.jpg
As you can see in this scene I have only 21 draw calls or lower. In-levels I never go over around 17-18. Can someone please help me figure out what the problem is?
Additional Info: Game runs at a constant 60fps on my HTC One, but that's because it's brand new. I can't just exclude any users who don't have a new device.
EDIT: I forgot to mention my game is a 2D game. For most things, I'm using a texture atlas and unity's built-in spriting system.
hmmm its not a big problem you can add me for help. http://www.facebook.com/azmatalimeer
Answer by iwaldrop · Dec 24, 2013 at 09:08 PM
Device.Present is called most often when Unity is waiting for VSync. In other words its simply waiting so that drawing can be in sync with the refresh rate of the device. What is probably happening is that it is taking slightly longer for you to draw a frame than the device can post them to the frame buffer which causes you to wait until the next frame to do anything.
Here are a couple things you can do to fix it:
Checkout the answer to this question. In short, your shaders can prefer OGLESv1 over v2.
Depending on your Unity Version there is either a checkbox or a dropdown to control VSync. Either uncheck it or select Don't Sync.
Ensure that Application.targetFrameRate is set to your desired target frame rate. Because you state that your HTC One does 60 fps, you may have already done this, but perhaps you have some logic that sets this dynamically and is acting up.
Evaluate your scene for overdraw (transparent textures that overlap); it can cause quite a lot of slow-down on older devices.
Also, try some of Statement's troubleshooting suggestions / potential fixes.
And, at the end of the day, old devices are not new devices, and will not perform the same. You didn't mention what device was getting the 15fps, but, in reality, you can exclude some older devices. At my shop, whenever an Android user complains of something not working right, we just remove the device from the allowed devices list on Google Play. It's just not worth the engineering resources for us to try and support all of those 4k+ devices.
After a ton of testing and building probably 30+ different builds with little things changed every time, I think I've come to the conclusion that the problem lies with just having too many transparent textures in the camera's view at any given time.
Actually, I tried building an empty game with a scene that had nothing in it, and the profiler still reported around 60% for Device.present. I didn't know what to make of that, though, which is why I assume it's transparencies.
But my game uses a lot of transparencies. I don't know how I can improve something like that aside from taking all my transparent textures and filling in the transparent parts and using a regular diffuse shader. But that'd look terrible.
I figured since I was using Unity's sprite system that it would be faster than using cubes or something.
I'm marking this as the answer because I believe the problem is overdraw after all since my game uses so many transparent textures. In the end I decided to forget about trying to change my game by changing all of the textures. Ins$$anonymous$$d I give the users an option to change the resolution to something smaller, which does increase fps a bunch.