That first shader has a ton of cruft. The Material block and associated variables doesn’t do anything, and Alphatest Greater 0 is ignored on iOS, because it’s a performance hit on PowerVR GPUs. There’s also no point in using Category. It can’t be improved, performance-wise, however:
Shader "Mobile/Transparent/Vertex Color" {
Properties {
_Color ("Main Color (A = Opacity)", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Fog {Mode Off}
BindChannels {
Bind "vertex", vertex
Bind "color", color
}
Pass {
SetTexture[_MainTex] {Combine texture * primary}
SetTexture[_MainTex] {
ConstantColor[_Color]
Combine previous * constant Double, previous * constant
}
}
}
}
Here’s what the GLSL converter spits out for your Cg (cleaned up a bit to compile as its own shader):
Shader "SRShaders/UsePassSnippets/UnlitDiffuseLightmap" {
SubShader {Pass {
Name "UNLIT"
GLSLPROGRAM
varying mediump vec2 xlv_TEXCOORD1;
varying mediump vec2 xlv_TEXCOORD0;
varying mediump vec4 xlv_COLOR;
#ifdef VERTEX
uniform mediump vec4 _MainTex_ST;
uniform mediump vec4 _LightMap_ST;
uniform lowp vec4 _Color;
void main () {
mediump vec4 tmpvar_1;
mediump vec4 tmpvar_2;
mediump vec2 tmpvar_3;
mediump vec2 tmpvar_4;
highp vec4 tmpvar_5;
tmpvar_5 = (gl_ModelViewProjectionMatrix * gl_Vertex);
tmpvar_1 = tmpvar_5;
highp vec2 tmpvar_6;
tmpvar_6 = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
tmpvar_3 = tmpvar_6;
highp vec2 tmpvar_7;
tmpvar_7 = ((gl_MultiTexCoord0.xy * _LightMap_ST.xy) + _LightMap_ST.zw);
tmpvar_4 = tmpvar_7;
tmpvar_2 = _Color;
gl_Position = tmpvar_1;
xlv_COLOR = tmpvar_2;
xlv_TEXCOORD0 = tmpvar_3;
xlv_TEXCOORD1 = tmpvar_4;
}
#endif
#ifdef FRAGMENT
uniform sampler2D _MainTex;
uniform sampler2D _LightMap;
void main () {
lowp vec4 tmpvar_1;
tmpvar_1 = texture2D (_LightMap, xlv_TEXCOORD1);
gl_FragColor = ((xlv_COLOR * 2.0) * (texture2D (_MainTex, xlv_TEXCOORD0) * (tmpvar_1 * tmpvar_1)));
}
#endif
ENDGLSL
}}
}
Using that medium precision variable in the fragment shader is destroying your performance, for absolutely no visual improvement. Unfortunately, I don’t yet know how to fix your Cg, to account for this, but here’s a cleaned up GLSL shader for you. According to PVRUnisco, the fragment shader is down from 15 cycles to 3. The vertex shader is down from 18 to 13. However, that’s only because five of those had been wasted on the varying color, which is unnecessary. (You might think to multiply it in the vertex shader, but it can be doubled in the fragment shader at no cost, as long as you use order and/or parentheses to help the compiler.)
Why you’re squaring the lightmap, I have no idea. If instead you meant to double it, that can save you a further cycle.
Shader "Give/This A Reasonable Name" {
Properties {
_Color ("Main Color", Color) = (1,1,1)
_MainTex ("Base", 2D) = ""
_LightMap ("Lightmap", 2D) = ""
}
SubShader {Pass {
Name "UNLIT"
GLSLPROGRAM
varying mediump vec2 mainUV, lightmapUV;
#ifdef VERTEX
uniform mediump vec4 _MainTex_ST, _LightMap_ST;
void main () {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
mainUV = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
lightmapUV = gl_MultiTexCoord0.xy * _LightMap_ST.xy + _LightMap_ST.zw;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex, _LightMap;
uniform lowp vec4 _Color;
void main () {
lowp vec4 lightmap = texture2D(_LightMap, lightmapUV);
gl_FragColor = texture2D(_MainTex, mainUV) * lightmap * lightmap * (_Color * 2.);
}
#endif
ENDGLSL
}}
}