Some shaders do not work on Android

syskranksyskrank Posts: 8Member
Hi everyone.

I'm making a 2D platformer and quite fascinated with what Godot engine is capable of. 

But now I'm on a struggle bus with some shading issues.

On desktop my 2D shaders seems to work quite well.

However, when I'm running my game on Android device they are gone.

I'm receiving the following messages from ADB whenever my shader should activate itself:

I/godot   (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:329.
I/godot   (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:329.
I/godot   (13606): ERROR: get_custom_uniform_location: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:336.
V/AudioTrack(13606): obtainBuffer(1536) returned 1536 = 1536 + 0 err 0
V/AudioTrack(13606): obtainBuffer(1024) returned 1024 = 1024 + 0 err 0
I/godot   (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:329.
I/godot   (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:329.
I/godot   (13606): ERROR: get_custom_uniform_location: Index p_idx out of size (version->custom_uniform_locations.size()).
I/godot   (13606):    At: ./drivers/gles2/shader_gles2.h:336.

All shaders are implemented within materials for the TextureFrame nodes.

Here's the example of one that doesn't work:

// this is a simple texture-based Vignette modulated shader
uniform texture vignette;
uniform float lightness;
uniform vec3 modulate;
vec3 _screen = texscreen( SCREEN_UV ).rgb;
vec4 _tex = tex(vignette, UV) * lightness;
// combine final color
color res = color( _tex.r, _tex.g, _tex.b, _tex.a);
res.rgb = mix( res.rgb, _screen.rgb, lightness );
res.rgb *= modulate;
COLOR = res;


Tagged:

Tags :

Answers

  • syskranksyskrank Posts: 8Member
    Answer ✓
    Hi again to everyone :)

    To not to break the establishing tradition of self-answering... I've found the solution to the aforementioned problem :)

    While looking into adb logcat I've stumbled across the following things:

    I/godot   (  419): ERROR: 0:124:5  __color containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 0:125:5  __bw_mult containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 0:126:1  __bw_mult containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 0:127:1  __color containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 0:128:17  __color containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 0:128:30  __bw_mult containing two consecutive underscores (__) is reserved as possible future keyword.
    I/godot   (  419): ERROR: 6 compilation errors. No code generated.

    Which are the shader compilation errors. Strange thing that I didn't use the two consecutive underscores, but I guess the names of the variables ( both local scope and uniform ) where the cause of all the mess.

    After renaming '_tex' to 'textureColor' and '_bw_mult' to 'modulate' ( and so on ), I've managed to get shaders work on Android.

    P.S.
    Btw, anyone knows what is the purpose of the 'Use driver GLES2' option within the project settings? It seems that GLES2 is used anyway, regardless to the checkbox state.
Sign In or Register to comment.