Particle Additive Shader on iPhone - Expensive?

Hi,

I’m using the Particle Additive Shader on iPhone and wondering if it’s an expensive shader to use. It gives me the result I am looking for, which is additive texture on top of my background.

And if it’s not OK to use it, what are the alternatives?

Thanks,

any transparent shader is “expensive”.
how expensive depends on the target device and how many pixels you overdraw with your particles.

on 4th gen iOS devices and the iPad you don’t have that much spare room for overdraws so limit the size of particles and their amount to reduce the overdraw should you get performance hits due to enabling them (-> test it with and without it to see if it is the cause)

I’m not using it for particles. I’m using it for a single plane, drawn over my background but covering about 80% of the screen. And there seems to be a big performance hit. Is there a way to optimize that? I’m not quite sure if I’m using the right shader to achieve what I want, which is basically transparency of the black pixels of the textures mapped on this plane.

Running on a second gen iPod, I get a 10 fps performance hit.

Is there a better way to do that?

Thanks,

Yes there is a way: don’t do it.

I know that sounds stupid, but what oyu do is redraw 80% of the screen once again which is a major problem on 4th gen and ipad due to the rather limited fillrate they have.

you should see if you can use distinct meshes to only redraw the parts you really need to redraw and not use shaders that blend at all unless required as materials that don’t blend cause no redraw on iOS hardware (it will just not draw what was behind it thanks to the highly optimized graphic chip)

Hehe, I see.

I’ll try to find a solution other than using transparency then. So, as a rule of thumb, transparency is a big No No for the iPhone, right?

Need more information about what you’re trying to do. You could potentially just put the whole thing into a single shader without blending. There are several things you can do to optimize the shader as-is. Take out ColorMask RGB to begin with.

Removing ColorMask RGB from the shader did the trick, my 10 FPS is back! :slight_smile:

Thanks a lot!

And to answer your question, I can’t put the whole thing in the same shader, since they are two separate objects on top of each others, with different materials. But your suggestion worked Jessy,just by removing the ColorMask RGB, I gained 10 fps (back to 60 again). :slight_smile:

Well 50 wouldn’t be slow, targeting 30 FPS is rather common due to the limitations of the device.
also a stable 30FPS feels more fluent than instable 40-60FPS due to the VSync enforcement of the device :slight_smile:

You are correct, I am targeting 30 FPS, but just testing under optimal performance to catch the obvious stuff slowing down my app dramatically.

Thanks a lot for the help guys. I appreciate. :slight_smile:

I see :slight_smile:
Just wanted to mention it so you don’t go on “phantom hunt” to get 60 FPS at any price

Just for the record and if someone else faces the same issue as me, I switched to the Mobile version of the shader: Mobile/Particles/Additive Culled. And removed the ColorMask RGB from it. And it gives me good performance, with a single plane covering 80% of the screen.

iPod second gen, iOS 4.1.

hehe, it’s tempting to give it a try, but like you’ve said, 30 FPS is reasonable for the iPhone and more realistic. :wink:

That’s not really enough info. Obviously you have two different shaders. I’m talking about writing your own shader; of course a built-in Unity one wouldn’t work. You can do a lot of creative combining, via matrices, multiple UV sets, and fast scripts. But as long as you have the performance you need, and it’s easy for you to work with, you’re all set. I’m reporting a bug right now to UT about the ColorMask thing. They’ve done a couple things in 3.0 to make people not have to think about what they’re putting in their shaders, but they haven’t addressed this yet.

I understand Jessy, and I have yet to read the Shaderlab documentation (I quickly glanced over it). I was just hoping that there was a Shader that I could use out of the box. But eventually (very soon) I’ll dig into the shader code to fully grasp what is going on, just haven’t had the time to do it yet.

Cheers! :slight_smile: