Hello Guest

Author Topic: Low fps on iPhone4  (Read 4729 times)

mukarillo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Low fps on iPhone4
« on: June 25, 2013, 03:46:27 am »
Hello guys, Im doing this app aiming ios devices and i achieved a good result at iPad, but when i put the same app in iPhone4, it gets lagged and low fps(10 fps). I read a bit about what was doing that and now i think its aboult the shader... my project has 6 animated objects and more than 15 textures, some of them i tween. 99% of them have alpha and i think iphone4 is having some trouble to render it...

My question is: whats the best/fast shader to use for iOS iPhone4 for these objects with alpha??

Thank you very much,
Murillo.


PS: i got this shader from internet but it keeps spamming "Shader wants normals, but the mesh  doesn't have them" on console.


Shader "Scripts/NewAlphaShader" {
    Properties {
        _Color ("Color Tint", Color) = (1,1,1,1)
        _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
    }
   
    Category {
       Lighting On
       ZWrite Off
       Cull Back
       Blend SrcAlpha OneMinusSrcAlpha
       Tags {Queue=Transparent}
       SubShader {
            Material {
               Emission [_Color]
            }
            Pass {
               SetTexture [_MainTex] {
                      Combine Texture * Primary, Texture * Primary
                }
            }
        }
    }
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Low fps on iPhone4
« Reply #1 on: June 25, 2013, 12:48:18 pm »
The blend vertex color shader included is possibly the simplest / most efficient shader you can have on there. The one below is far more expensive, as it is lit.

Most of the time, you need to work out what your bottleneck is. If you're drawing lots of transparent sprites on top of each other, then there isn't much you can do except draw less. Look in the overdraw preview in Unity, and see how much you're overdrawing. 6 animated objects and number of textures doesn't really mean anything, ultimately, what matters is how much overdraw you're creating. If you have 6 animated objects, all full screen, then you're going to be seriously kiling performance especially on fill rate limited devices like iPhone4.
« Last Edit: June 25, 2013, 03:52:18 pm by unikronsoftware »

mukarillo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Low fps on iPhone4
« Reply #2 on: June 25, 2013, 03:50:16 pm »
Hello again, and thanks for asking me.

While reading your text, i might figured out what was wrong with my project... and i could reach 35fps by changing the shader and stuff, but here's the real problem:
I have a paralax background that is a mix of 8 images of the size 1500x 768, they all have alpha in them... (my project has 3000 total width, i cut the image in half to run in iPhone4, so i put these 1500 x 768 images one beside of another)

how can i avoid having those giant images??

i tried static batching but i the frame rate still the same, i think when i move them with my paralax script the static batch is ignored :/

Thank you very much again!
Murillo.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Low fps on iPhone4
« Reply #3 on: June 25, 2013, 03:55:31 pm »
I don't think your bottleneck is the shader, it is likely the overdraw. Its hard to suggest something without actually being able to see what exactly you're trying to do, but a simple tip - if you have something that is solid in your background, eg. a sky or like that, use a solid shader on it. It will be miles faster.

Static sprite batching isn't going to help, that reduces cpu work, not GPU. You're likely fillrate / very unlikely shader bound, so none of that's gonna help. If your images have a lot of empty spaces, use dicing (http://unikronsoftware.com/2dtoolkit/doc/2.00/advanced/sprite_optimizations/sprite_optimizations.html) to reduce fillrate.

mukarillo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Low fps on iPhone4
« Reply #4 on: June 25, 2013, 06:10:32 pm »
Omg, that's awesome!!

I'll try this when i get home tonight.

Thanks for the great support!