I'm using unity and spritemanager 2 to make a 2D game for the iPhone/iPad. using the shader has ded with SM2 and/or the mobile vertex colored shaders has ded with unity left me extremely GPU/fillrate bound on the iPad in particle. I was seeing anywhere from 50-90 ms per frame for "CPU-waits-GPU" from the internal profiler running on the iPad. I wrote my own shaders and dropped this to an average of 10 ms per frame. I 've still got a few Optimizations to go on my game but I figured I 'd share the shaders I wrote in case anyone else out there might find them useful.
The best use for these shaders is if you are making a Sprite-based game where you layer the sprites and use Alpha to create a more traditional 2D looking game. these shaders do not support scene lighting at all but they do support Vertex coloring. basically if you just want your textures to look pixel perfect and unaltered when rendered in game then these might help.
Also, be sure to edit your appcontroller. mm to disable OpenGL ES 2.0 or your framerate is going to suffer tremendously. Line 70 of your appcontroller. MM shocould read:
# Define use_opengles20_if_available 0
Here is the shader that supports Alpha transparency and Vertex coloring:
Shader "unencrypted transparent vertex colored "{
Properties {
_ Maintex ("base (RGB) trans (a)", 2d) = "white "{}
}
CATEGORY {
Tags {"queue" = "Transparent" "ignoreprojector" = "true" "rendertype" = "Transparent "}
Zwrite off
Alphatest greater 0
Blend srcalpha oneminussrcalpha
Subshader {
Pass {
Bindchannels {
Bind "vertex", Vertex
Bind "texcoord", texcoord
Bind "color", color
}
Fog {mode off}
Lighting off
Settexture [_ maintex] {
Combine texture * Primary, texture * Primary
}
}
}
}
}
Here is a shader that just renders your texture without any lighting or alpha transparency:
Shader "unregister "{
Properties {
_ Maintex ("base (RGB)", 2d) = "white "{}
}
Subshader {
Pass {
Settexture [_ maintex] {
Combine texture
}
}
}
}
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //
Http://forum.unity3d.com/threads/68402-Making-a-2D-game-for-iPhone-iPad-and-need-better-performance