Hi,
I will be designing an effects pack for top down space shooter game and need some advice. This topic is not new for me. I’ve written shaders before and know the graphics pipeline fairly well, I think. Mostly I’ve written stuff for desktop, but I’ve also optimized shaders for mobile devices. I’m aware of mobile device limitations, like draw calls, fill rate, alpha blending and testing, texture lookups to name the main ones. For mobile, everything must be very tight. This is why I’m asking advice. Maybe something I’m thinking about trying out is just not worth the effort. Maybe you have some neat idea to share.
Specs:
- Target is mobile phones and tablets, iOS and Android
- No need to support lower end devices (iPad 4th generation and up, Samsung Galaxy SIII, Samsung Galaxy Tab 2, Google Nexus 7 first generation, etc. About a year old decent tablet or phone should be able to run it)
- Effects will be almost all 2D
- There will be a lot of them simultaneously on screen
- OpenGL ES 2
- using Unity Pro
My first concern is alpha blending. That’s a tough one. My current idea is to separate “local” blend effects like laser hit sparks from “global” blend effects like tinting some portion of the screen (fog, energy field, etc). The “global” effect would use one relatively low resolution texture, that is updated on CPU side, so that the fragment shader would be as small as possible. I hope it’ll amortize the cost of larger effects on high dpi screens. “Local” blend effects would use as few pixels as possible, but still, when there are many of them on screen the blending cost will become problematic, but I don’t see what I could do here.
Texture lookups are more costly than a few more fragment shaders ops on desktop. Is it true for mobile too? Maybe it’s better to compute a texture on the fly in fragment shader (would use UV and some other parameters). A forcefield around a ship is symmetric enough for this. Is it worth to try it out?
What would be a texture memory footprint I should aim for? I know, the smaller the better, but realistically, how far up I can go, before I get into trouble.
How to pass meshes to the graphics pipeline? Is the regular way of using meshes and relaying on dynamic batching a good way to go? Maybe I should try to build things around API calls like Graphics DrawMesh and GL class methods?
Should I try using builtin particle system or should I write small optimized scripts that animate mesh vertices or mesh instances on it’s own? I guess the particle system is well optimized, but it may also be too bloated, idk.
Anything else I haven’t thought about, but really should?
Great thanks to you guys who take time to read it and replay ![]()