Shaders [SOLVED] Shader uniform not passing the values to the shader on Android device

Hello, I have the following code on my main object which draws the sprites.

####################### DRAW EVENT OF MAIN OBJECT #########################
shader_set(shd_colorchange);
shader_set_uniform_f(shader_get_uniform(shd_colorchange, "u_v4_wantedColor"), 1.0, 0.0, 1.0);
draw_sprite_ext(spr_enemy, 0, x, y, 1, 1, 0, c_white, 1)
shader_reset();
##########################################################################

And this is my shader code.

########################## FRAGMENT SHADER CODE ###########################
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec4 u_v4_wantedColor;

void main()
{
vec4 base_col = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord);
vec4 new_col;

new_col.r = u_v4_wantedColor.r;
new_col.g = u_v4_wantedColor.g;
new_col.b = u_v4_wantedColor.b;
new_col.a = 1.0;

gl_FragColor = new_col;
}
##########################################################################

On Windows, the code works perfectly fine, it draws the sprite with a purple color.

When I run the game on Android, the uniform rgb values seem to become 0,0,0 because the output color is black. So the problem seems that on Android devices something happens with the uniform before it is given to the shader.

When I write the rgb values directly into the shader code without using a uniform, it also works on Android so it can not be my Android device's GPU.

Graphic settings in the attachment.

Please help!
 

Attachments

Nidoking

Member
shader_set_uniform_f(shader_get_uniform(shd_colorchange, "u_v4_wantedColor"), 1.0, 0.0, 1.0);
Why are you passing only three values to a four-value vector? My guess would be that the Windows compiler figures you don't know what you're doing and just sticks some default value in the fourth position, which you don't use, but the Android compiler expects some ability to count and refuses to hold your hand.
 
Why are you passing only three values to a four-value vector? My guess would be that the Windows compiler figures you don't know what you're doing and just sticks some default value in the fourth position, which you don't use, but the Android compiler expects some ability to count and refuses to hold your hand.
Thank you so much Nidoking, this instantly solved my problem :)
 
Solution: Always pass 4 Values to the shader uniform instead of 3, the windows compiler will forgive you and insert default values but Android won't and the solution is a failing shader.
 
Top