Results 1 to 2 of 2

Thread: Simple Shader Fails [Android, OpenGL]

  1. #1
    Newbie
    Join Date
    Nov 2017
    Posts
    1

    Simple Shader Fails [Android, OpenGL]

    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
    Code :
    gl_FragColor = mix(originalrgb.rgba, colorizedOutput.rgba, 0.5);
    , it works.

    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

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    20
    Quote Originally Posted by qwertyuiop View Post
    Code glsl:
    uniform samplerExternalOES sTexture;
    ...
        vec4 originalrgb = vec4((texture2D(sTexture, v_TexCoord).rgb), 1.0);
    ...
        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.
    You appear to be missing a "#extension GL_OES_EGL_image_external" at the top of your shader, per the extension spec.
    Last edited by Dark Photon; 11-28-2017 at 12:07 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean