fragment evaluation shader compile error

I have a problem with shaders not being loaded/compiled on Android. It seems to occur mainly on devices with PowerVR 540 Series GPUs.

There is one Shader it can not compile - but I’m actually not using this shader or I don’t know where it is uses. Is there any way to find out?

Here is the error message from adb.

#version 100
D/Unity   (26077): uniform sampler2D _MainTex;
D/Unity   (26077): uniform lowp float _Cutoff;
D/Unity   (26077): uniform bvec4 unity_MetaFragmentControl;
D/Unity   (26077): uniform highp float unity_OneOverOutputBoost;
D/Unity   (26077): uniform highp float unity_MaxOutputValue;
D/Unity   (26077): uniform highp float unity_UseLinearSpace;
D/Unity   (26077): varying highp vec2 xlv_TEXCOORD0;
D/Unity   (26077): varying lowp vec4 xlv_COLOR0;
D/Unity   (26077): void main ()
D/Unity   (26077): {
D/Unity   (26077):   lowp vec4 tmpvar_1;
D/Unity   (26077):   mediump vec3 tmpvar_2;
D/Unity   (26077):   lowp vec3 tmpvar_3;
D/Unity   (26077):   lowp vec4 tmpvar_4;
D/Unity   (26077):   tmpvar_4 = (texture2D (_MainTex, xlv_TEXCOORD0) * xlv_COLOR0);
D/Unity   (26077):   tmpvar_3 = tmpvar_4.xyz;
D/Unity   (26077):   lowp float x_5;
D/Unity   (26077):   x_5 = (tmpvar_4.w - _Cutoff);
D/Unity   (26077):   if ((x_5 < 0.0)) {
D/Unity   (26077):     discard;
D/Unity   (26077):   };
D/Unity   (26077):   tmpvar_2 = tmpvar_3;
D/Unity   (26077):   mediump vec4 res_6;
D/Unity   (26077):   res_6 = vec4(0.0, 0.0, 0.0, 0.0);
D/Unity   (26077):   if (unity_MetaFragmentControl.x) {
D/Unity   (26077):     mediump vec4 tmpvar_7;
D/Unity   (26077):     tmpvar_7.w = 1.0;
D/Unity   (26077):     tmpvar_7.xyz = tmpvar_2;
D/Unity   (26077):     res_6.w = tmpvar_7.w;
D/Unity   (26077):     highp vec3 tmpvar_8;
D/Unity   (26077):     tmpvar_8 = clamp (pow (tmpvar_2, vec3(clamp (unity_OneOverOutputBoost, 0.0, 1.0))), vec3(0.0, 0.0, 0.0), vec3(unity_MaxOutputValue));
D/Unity   (26077):     res_6.xyz = tmpvar_8;
D/Unity   (26077):   };
D/Unity   (26077):   if (unity_MetaFragmentControl.y) {
D/Unity   (26077):     mediump vec3 emission_9;
D/Unity   (26077):     if (bool(unity_UseLinearSpace)) {
D/Unity   (26077):       emission_9 = vec3(0.0, 0.0, 0.0);
D/Unity   (26077):     } else {
D/Unity   (26077):       emission_9 = vec3(0.0, 0.0, 0.0);
D/Unity   (26077):     };
D/Unity   (26077):     mediump vec4 tmpvar_10;
D/Unity   (26077):     highp vec4 rgbm_11;
D/Unity   (26077):     highp vec4 tmpvar_12;
D/Unity   (26077):     tmpvar_12.w = 1.0;
D/Unity   (26077):     tmpvar_12.xyz = (emission_9 * 0.01030928);
D/Unity   (26077):     rgbm_11.xyz = tmpvar_12.xyz;
D/Unity   (26077):     rgbm_11.w = max (max (tmpvar_12.x, tmpvar_12.y), max (tmpvar_12.z, 0.02));
D/Unity   (26077):     rgbm_11.w = (ceil((rgbm_11.w * 255.0)) / 255.0);
D/Unity   (26077):     rgbm_11.w = max (rgbm_11.w, 0.02);
D/Unity   (26077):     rgbm_11.xyz = (tmpvar_12.xyz / rgbm_11.w);
D/Unity   (26077):     tmpvar_10 = rgbm_11;
D/Unity   (26077):     res_6 = tmpvar_10;
D/Unity   (26077):   };
D/Unity   (26077):   tmpvar_1 = res_6;
D/Unity   (26077):   gl_FragData[0] = tmpvar_1;
D/Unity   (26077): }
D/Unity   (26077): fragment evaluation shader
D/Unity   (26077): Compile failed.

Any Help wolud be appreciated

I doubt that this is all that got printed to the log. Even when it is the problem is that this shader most likely doesn’t have a fallback. The actual problem in the shader is probably the “discard” statement which isn’t supported on many mobile GPUs. “discard” is usually used by most cutout shaders.

As you can see in the code in line 19-22 it checks if the alpha value is smaller than the given cutout value. If it is, it simply discards the current fragment so nothing gets written to the frame buffer.