Hi
I’m new to using OpenGL ES2.0 on Android but I have a basic 2d game working with simple shaders.
I’m having a nightmare trying to modify a simple fragment shader. If I try and re-assign a variable the shader stops working or does something strange. All the example shaders I have found on the internet re-assign variables.
my fragment shader is like this:
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
vec4 test = vec4(0.0, 0.0, 1.0, 0.5);
vec2 test2 = vec2(0.0,0.0); // this variable is not used but shader still works OK
// re-assigning a variable stops the shader working, nothing is rendered
test2 = vec2(0.0, 0.0); // if I comment this line out the shader works OK again
void main() {
gl_FragColor = texture2D( s_texture, v_texCoord ) * test ;
};
Any ideas why the line
test2 = vec2(0.0, 0.0);
should stop the shader working.
I have also tried
vec2 test2;
test2 = vec2(0.0, 0.0);
but that doesn’t work either.
I can only assign a variable value when the variable is declared.
Any help or suggestions would be appreciated.