Which one of the mobile transparent shaders is currently the fastest? Or should I better try to make my own?
the mobile ones are at the edge of where you can go, you can’t get any faster.
The major problem of transparent in the context of performance is unavoidable: its transparent and thus fillrate hungry as it automatically means redraw
I read that the vertex lit is the fastest of the mobile shaders
Generally. The built-in shaders can’t account for everything you’d want to do, with maximum efficiency. You ask which one is the fastest, but that doesn’t really make any sense. You shouldn’t pick a shader and then make art based on its limitations. You should decide what you need, and use a shader that provides for only that. It may be better to complicate the material a little bit, if it will help with atlasing/batching, however.
What I want is a shader for cloud particles.
So far I’m happy with this one - any nonsense in this shader or is there something to make it faster?
Shader "Mobile/TransparentShader"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Blend SrcAlpha OneMinusSrcAlpha
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off
Lighting Off
Pass
{
GLSLPROGRAM
#ifdef VERTEX
varying lowp vec2 uv;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
varying lowp vec2 uv;
void main()
{
gl_FragColor = texture2D(_MainTex, uv);
}
#endif
ENDGLSL
}
}
}
If that gives you the effect you need, it’s not going to get any faster (except maybe for the precision switch I’m about to suggest). However…
- (RGB) is a lie.
- Lighting Off is useless.
- Putting a varying in both parts of the shader is unnecessary. Just use global scope.
- lowp is not a speed benefit for the UVs. highp might be fine in this case, but there’s an Apple doc that suggests that texture2D might take a mediump. So I’m not sure what would be faster, but bump it up.
Shader warning in ‘Mobile/TransparentShader’: Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)