title: OpenGL ES 2.0 transparency using alpha testing in shader
body: <p>I'm trying to make transparent object in OpenGL ES 2.0. I'm setting up GL w/ following params:</p>
  
  <pre><code>    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
      GLES20.glDepthFunc(GLES20.GL_LESS);
      GLES20.glDisable(GLES20.GL_BLEND);
      GLES20.glClearDepthf(1.0f);
  </code></pre>
  
  <p>Here is the code for shaders:</p>
  
  <pre><code>private final String mVertexShader = "uniform mat4 uMVPMatrix;\n" +
          "attribute vec4 aPosition;\n" +
          "attribute vec2 aTextureCoord;\n" +
          "varying vec2 vTextureCoord;\n" +
          "void main() {\n" +
          "  gl_Position = uMVPMatrix * aPosition;\n" +
          "  vTextureCoord = aTextureCoord;\n" +
          "}\n";
  
  private final String mFragmentShader = "precision mediump float;\n" +
          "varying vec2 vTextureCoord;\n" +
          "uniform sampler2D sTexture;\n" +
          "void main() {\n" +
          "  vec4 base = texture2D(sTexture, vTextureCoord);\n" +
          "  if(base.a &lt; 0.5){ discard; }\n" +
          "  gl_FragColor = base;\n" +
          "}\n";
  </code></pre>
  
  <p>Resulting images of rendering: <a href="http://imgur.com/hNqm0" rel="nofollow">http://imgur.com/hNqm0</a> <a href="http://imgur.com/dmS2O" rel="nofollow">http://imgur.com/dmS2O</a>.
  Please tell me what I'm doing wrong, it renders fine in Rendermonkey OpenGL ES mode.</p>
  
  <p>If I use</p>
  
  <pre><code>    GLES20.glDisable(GLES20.GL_BLEND);
  </code></pre>
  
  <p>for initializing OpenGL I get correct transparency but without ordering of triangles. May be some sorting will help in this case?</p>