title: Using opengl es shader to convert YUV to RGB
body: <p>I want to convert yuv to rgb in opengl es shader with just one sampler which contains yuv data. My code is below:</p>
  
  <p>1) I send yuv data to texture:</p>
  
  <pre><code>GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_LUMINANCE,
              mData.w, mData.h * 3 / 2, 0, GLES20.GL_LUMINANCE,
              GLES20.GL_UNSIGNED_BYTE, ByteBuffer.wrap(mData.yuv));
  </code></pre>
  
  <p>2) My vertex shader:</p>
  
  <pre><code>attribute vec4 position;
  attribute vec2 inputTextureCoordinate;
  attribute mediump float width;
  
  varying vec2 v_texCoord;
  varying mediump vec2 v_vuTexCoord;
  varying mediump float x_coord;
  
  void main()
  {
      gl_Position = position;
      v_texCoord = vec2(inputTextureCoordinate.x, inputTextureCoordinate.y * 0.6666667);
      v_vuTexCoord = vec2(inputTextureCoordinate.x, inputTextureCoordinate.y * 0.333333 + 0.6666667);
      x_coord = floor(inputTextureCoordinate.x * width);
  }
  </code></pre>
  
  <p>3) My fragment shader:</p>
  
  <pre><code>uniform sampler2D inputImageTexture;  
  varying mediump vec2 v_texCoord;
  varying mediump vec2 v_vuTexCoord;
  varying mediump float x_coord;
  uniform mediump float u_one_over_tex_size;
  
  void main()
  {
      mediump vec3 yuv;
      mediump vec3 rgb;
      mediump float valx = mod(x_coord , 2.0);
      if(valx &lt; 1.0) 
      {
          yuv.y = texture2D(inputImageTexture, v_vuTexCoord + vec2(u_one_over_tex_size, 0)).r - 0.5;
          yuv.z = texture2D(inputImageTexture, v_vuTexCoord).r - 0.5;
      } 
      else {
          yuv.y = texture2D(inputImageTexture, v_vuTexCoord).r - 0.5;
          yuv.z = texture2D(inputImageTexture, v_vuTexCoord + vec2(u_one_over_tex_size, 0)).r - 0.5;
      }
      yuv.x = texture2D(inputImageTexture, v_texCoord).r;
      rgb = mat3(    1,       1,     1,
                     0, -.34413, 1.772,
                 1.402, -.71414,     0) * yuv;
      gl_FragColor = vec4(rgb, 1);
  }
  </code></pre>
  
  <p>But the result is not as I thought. If I split yuv data to y and uv samplers and change vertex and fragment shader, and I can have the right result. But how could I only send a sampler just<br>
  like above?</p>