[5.x] shader fails to compile on Android OpenGLES2

Hi, as many others we are having trouble with performance on Android. After trying many tests, we concluded that mainly, for us, the problem lays on OpenGLES2.0 devices, like the Galaxy Nexus. Looking at the logs, we see shaders fail to compile, and we only use the default sprite shader. Is there a way to “hack” this shader to change it?

Any help would be appreciated!

Here is part of the logs:

09-23 16:33:16.993: D/Unity(20153): -------- Shader compilation failed
09-23 16:33:16.993: D/Unity(20153): #version 100
09-23 16:33:16.993: D/Unity(20153): #extension GL_EXT_shader_texture_lod : enable
09-23 16:33:16.993: D/Unity(20153): lowp vec4 impl_low_textureCubeLodEXT(lowp samplerCube sampler, highp vec3 coord, mediump float lod)
09-23 16:33:16.993: D/Unity(20153): {
09-23 16:33:16.993: D/Unity(20153): #if defined(GL_EXT_shader_texture_lod)
09-23 16:33:16.993: D/Unity(20153): return textureCubeLodEXT(sampler, coord, lod);
09-23 16:33:16.993: D/Unity(20153): #else
09-23 16:33:16.993: D/Unity(20153): return textureCube(sampler, coord, lod);
09-23 16:33:16.993: D/Unity(20153): #endif
09-23 16:33:16.993: D/Unity(20153): }
09-23 16:33:16.993: D/Unity(20153): uniform mediump vec4 _TexA_HDR;
09-23 16:33:16.993: D/Unity(20153): uniform mediump vec4 _TexB_HDR;
09-23 16:33:16.993: D/Unity(20153): uniform lowp samplerCube _TexA;
09-23 16:33:16.993: D/Unity(20153): uniform lowp samplerCube _TexB;
09-23 16:33:16.993: D/Unity(20153): uniform highp float _Level;
09-23 16:33:16.993: D/Unity(20153): uniform highp float _value;
09-23 16:33:16.993: D/Unity(20153): varying highp vec3 xlv_TEXCOORD0;
09-23 16:33:16.993: D/Unity(20153): void main ()
09-23 16:33:16.993: D/Unity(20153): {
09-23 16:33:16.993: D/Unity(20153): mediump vec3 res_1;
09-23 16:33:16.993: D/Unity(20153): mediump vec4 tmpvar_2;
09-23 16:33:16.993: D/Unity(20153): lowp vec4 tmpvar_3;
09-23 16:33:16.993: D/Unity(20153): tmpvar_3 = impl_low_textureCubeLodEXT (_TexA, xlv_TEXCOORD0, _Level);
09-23 16:33:16.993: D/Unity(20153): tmpvar_2 = tmpvar_3;
09-23 16:33:16.993: D/Unity(20153): mediump vec3 tmpvar_4;
09-23 16:33:16.993: D/Unity(20153): tmpvar_4 = ((_TexA_HDR.x * tmpvar_2.w) * tmpvar_2.xyz);
09-23 16:33:16.993: D/Unity(20153): mediump vec4 tmpvar_5;
09-23 16:33:16.993: D/Unity(20153): lowp vec4 tmpvar_6;
09-23 16:33:16.993: D/Unity(20153): tmpvar_6 = impl_low_textureCubeLodEXT (_TexB, xlv_TEXCOORD0, _Level);
09-23 16:33:16.993: D/Unity(20153): tmpvar_5 = tmpvar_6;
09-23 16:33:16.993: D/Unity(20153): mediump vec3 tmpvar_7;
09-23 16:33:16.993: D/Unity(20153): tmpvar_7 = ((_TexB_HDR.x * tmpvar_5.w) * tmpvar_5.xyz);
09-23 16:33:16.993: D/Unity(20153): highp vec3 tmpvar_8;
09-23 16:33:16.993: D/Unity(20153): tmpvar_8 = mix (tmpvar_4, tmpvar_7, vec3(_value));
09-23 16:33:16.993: D/Unity(20153): res_1 = tmpvar_8;
09-23 16:33:16.993: D/Unity(20153): mediump vec4 tmpvar_9;
09-23 16:33:16.993: D/Unity(20153): tmpvar_9.w = 1.0;
09-23 16:33:16.993: D/Unity(20153): tmpvar_9.xyz = res_1;
09-23 16:33:16.993: D/Unity(20153): gl_FragData[0] = tmpvar_9;
09-23 16:33:16.993: D/Unity(20153): }
09-23 16:33:17.000: D/Unity(20153): -------- failed compiling:
09-23 16:33:17.000: D/Unity(20153): fragment evaluation shader
09-23 16:33:17.000: D/Unity(20153): -------- GLSL error:
09-23 16:33:17.000: D/Unity(20153): Compile failed.
09-23 16:33:17.000: D/Unity(20153): ERROR: 0:8: ‘textureCubeLodEXT’ : no matching overloaded function found
09-23 16:33:17.000: D/Unity(20153): ERROR: 0:8: ‘return’ : function return is not matching type
09-23 16:33:17.000: D/Unity(20153): ERROR: 2 compilation errors. No code generated.
09-23 16:33:17.000: D/Unity(20153): textureCubeLodEXT or textureCubeGradEXT usage detected.
09-23 16:33:17.000: D/Unity(20153): GL_EXT_shader_texture_lod extension is buggy on PowerVR drivers.
09-23 16:33:17.000: D/Unity(20153): replacing textureCubeLodEXT->textureCubeLod and textureCubeGradEXT->textureCubeGradARB as a workaround.
09-23 16:33:18.789: D/Unity(20153): -------- Shader compilation failed
09-23 16:33:18.789: D/Unity(20153): #version 100
09-23 16:33:18.789: D/Unity(20153): #extension GL_EXT_shader_texture_lod : enable
09-23 16:33:18.789: D/Unity(20153): lowp vec4 impl_low_textureCubeLodEXT(lowp samplerCube sampler, highp vec3 coord, mediump float lod)
09-23 16:33:18.789: D/Unity(20153): {
09-23 16:33:18.789: D/Unity(20153): #if defined(GL_EXT_shader_texture_lod)
09-23 16:33:18.789: D/Unity(20153): return textureCubeLodEXT(sampler, coord, lod);
09-23 16:33:18.789: D/Unity(20153): #else
09-23 16:33:18.789: D/Unity(20153): return textureCube(sampler, coord, lod);
09-23 16:33:18.789: D/Unity(20153): #endif
09-23 16:33:18.789: D/Unity(20153): }
09-23 16:33:18.789: D/Unity(20153): uniform lowp samplerCube _MainTex;
09-23 16:33:18.789: D/Unity(20153): uniform mediump float _Level;
09-23 16:33:18.789: D/Unity(20153): varying mediump vec4 xlv_TEXCOORD0;
09-23 16:33:18.789: D/Unity(20153): void main ()
09-23 16:33:18.789: D/Unity(20153): {
09-23 16:33:18.789: D/Unity(20153): mediump vec4 tmpvar_1;
09-23 16:33:18.789: D/Unity(20153): lowp vec4 tmpvar_2;
09-23 16:33:18.789: D/Unity(20153): tmpvar_2 = impl_low_textureCubeLodEXT (_MainTex, xlv_TEXCOORD0.xyz, _Level);
09-23 16:33:18.789: D/Unity(20153): tmpvar_1 = tmpvar_2;
09-23 16:33:18.789: D/Unity(20153): gl_FragData[0] = tmpvar_1;
09-23 16:33:18.789: D/Unity(20153): }
09-23 16:33:18.789: D/Unity(20153): -------- failed compiling:
09-23 16:33:18.789: D/Unity(20153): fragment evaluation shader
09-23 16:33:18.789: D/Unity(20153): -------- GLSL error:
09-23 16:33:18.789: D/Unity(20153): Compile failed.
09-23 16:33:18.789: D/Unity(20153): ERROR: 0:8: ‘textureCubeLodEXT’ : no matching overloaded function found
09-23 16:33:18.789: D/Unity(20153): ERROR: 0:8: ‘return’ : function return is not matching type
09-23 16:33:18.789: D/Unity(20153): ERROR: 2 compilation errors. No code generated.
09-23 16:33:18.789: D/Unity(20153): textureCubeLodEXT or textureCubeGradEXT usage detected.
09-23 16:33:18.789: D/Unity(20153): GL_EXT_shader_texture_lod extension is buggy on PowerVR drivers.
09-23 16:33:18.789: D/Unity(20153): replacing textureCubeLodEXT->textureCubeLod and textureCubeGradEXT->textureCubeGradARB as a workaround.
09-23 16:33:19.688: D/Unity(20153): -------- Shader compilation failed
09-23 16:33:19.688: D/Unity(20153): #version 100
09-23 16:33:19.688: D/Unity(20153): #extension GL_EXT_shader_texture_lod : enable
09-23 16:33:19.688: D/Unity(20153): lowp vec4 impl_low_textureCubeLodEXT(lowp samplerCube sampler, highp vec3 coord, mediump float lod)
09-23 16:33:19.688: D/Unity(20153): {
09-23 16:33:19.688: D/Unity(20153): #if defined(GL_EXT_shader_texture_lod)
09-23 16:33:19.688: D/Unity(20153): return textureCubeLodEXT(sampler, coord, lod);
09-23 16:33:19.688: D/Unity(20153): #else
09-23 16:33:19.688: D/Unity(20153): return textureCube(sampler, coord, lod);
09-23 16:33:19.688: D/Unity(20153): #endif
09-23 16:33:19.688: D/Unity(20153): }
09-23 16:33:19.688: D/Unity(20153): uniform highp float _Level;
09-23 16:33:19.688: D/Unity(20153): uniform lowp samplerCube _MainTex;
09-23 16:33:19.688: D/Unity(20153): varying highp vec4 xlv_TEXCOORD0;
09-23 16:33:19.688: D/Unity(20153): void main ()
09-23 16:33:19.688: D/Unity(20153): {
09-23 16:33:19.688: D/Unity(20153): highp vec4 tmpvar_1;
09-23 16:33:19.688: D/Unity(20153): lowp vec4 tmpvar_2;
09-23 16:33:19.688: D/Unity(20153): tmpvar_2 = impl_low_textureCubeLodEXT (_MainTex, xlv_TEXCOORD0.xyz, _Level);
09-23 16:33:19.688: D/Unity(20153): tmpvar_1 = tmpvar_2;
09-23 16:33:19.688: D/Unity(20153): gl_FragData[0] = tmpvar_1;
09-23 16:33:19.688: D/Unity(20153): }
09-23 16:33:19.688: D/Unity(20153): -------- failed compiling:
09-23 16:33:19.688: D/Unity(20153): fragment evaluation shader
09-23 16:33:19.688: D/Unity(20153): -------- GLSL error:
09-23 16:33:19.688: D/Unity(20153): Compile failed.
09-23 16:33:19.688: D/Unity(20153): ERROR: 0:8: ‘textureCubeLodEXT’ : no matching overloaded function found
09-23 16:33:19.688: D/Unity(20153): ERROR: 0:8: ‘return’ : function return is not matching type
09-23 16:33:19.688: D/Unity(20153): ERROR: 2 compilation errors. No code generated.
09-23 16:33:19.688: D/Unity(20153): textureCubeLodEXT or textureCubeGradEXT usage detected.
09-23 16:33:19.688: D/Unity(20153): GL_EXT_shader_texture_lod extension is buggy on PowerVR drivers.
09-23 16:33:19.688: D/Unity(20153): replacing textureCubeLodEXT->textureCubeLod and textureCubeGradEXT->textureCubeGradARB as a workaround.

1 Like

Hm no one has stumbled upon this? the Nexus isnt THAT old…I think it may have to do with the GPU which is a PowerVR SGX540 and the capabilities it has, because i didnt change any default shader.

Galaxy Nexus came out in 2011…in the mobile market, it is ancient. That said…I think it should be able to handle simple scenes. I’ll find mine and see if I can get a blank scene running.

did you find any workaround ?

i have same problem.

the S4 Android device, the Unity 5.2.3.

if you have some solution, please tell me ,too.

thank you in advance.

Looks like the shaders are designed to sample cubemaps, and are failing to compile due to the PowerVR GPU being present… what shader are you actually using?

EDIT: On second thought, it looks like Unity’s to blame; why would a function be removed, but have a function reference still there? On second thought, I am thinking that maybe the unity function references aren’t declared properly… To me, this reeks of yet another Unity 5.x bug!

I am having this problem on linux, new unity 5.3 fails to compile shaders

you have to use -force-opengl because some devices don’t support opengl 3.2 which is what unity 5.3 changed to -_-

Of course… :smile: Why aren’t there feature levels? (Or maybe they’re there… in that case, bug?)

And I think OpenGL 3.0’s minimum, as my laptop’s OpenGL 3.1 in linux, and seems to work fine in unity linux. (I guess I could always test 5.3, just to make sure of this)

EDIT: On top of that, forcing GLCore profile in a built game on linux works there too. (It’s buggy however… :smile:)