I have a simple shader code. I pass in two image texture (NOTE: One is samplerExternalOES and other one is sampler2D).
The first texture 'sTexture' is the original image i get from a camera frame. The second texture 'sTexture2' is a mask i get from the cpu.
The shader fails on the 'mix' function.
The shader is as follows:
Code :uniform samplerExternalOES sTexture; uniform sampler2D sTexture2; varying vec2 v_TexCoord; void main(void) { vec4 originalrgb = vec4((texture2D(sTexture, v_TexCoord).rgb), 1.0); vec4 floodfillimage = vec4((texture2D(sTexture2, v_TexCoord).rgb), 1.0); /*Code To Colour Input Image with Blue Tint Color*/ vec4 c = vec4(0.0, 1.0, 1.0, 1); vec4 inputColor = vec4((texture2D(sTexture, v_TexCoord).rgb), 1.0); float average = (inputColor.r + inputColor.g + inputColor.b) / 3.0; vec4 grayscale = vec4(average, average, average, 1.0); vec4 colorizedOutput = grayscale * c ; /*Code To mix original image with blue coloured based on another floodfilledimage passed in */ gl_FragColor = mix(originalrgb.rgba, colorizedOutput.rgba, floodfillimage.r); }
The error i recieve is glerror 1282, which means GL_INVALID_OPERATION. I've debugged and found out this happens on the mix function line.
NOTE: If I change the last line to, it works.Code :gl_FragColor = mix(originalrgb.rgba, colorizedOutput.rgba, 0.5);
So, why is it that the code panics when i do?Code :floodfillimage.r
Thank You.
EDIT I've tested both textures passed in (ie, i just rendered them to gl_FragColor) and they both are the image they're suppose to be