Skip to content

Instantly share code, notes, and snippets.

@danzeeeman
Last active August 29, 2015 14:05
Show Gist options
  • Save danzeeeman/b0b1a2a5174f7da45d0a to your computer and use it in GitHub Desktop.
Save danzeeeman/b0b1a2a5174f7da45d0a to your computer and use it in GitHub Desktop.
AlphaTest for openGL ES2
alphatest.frag
=======
precision highp float;
uniform sampler2D tex0;
uniform float alpha;
varying vec2 texCoordVarying;
void main()
{
vec4 texel0 = texture2D(tex0, texCoordVarying);
if(texel0.a > 0.1){
gl_FragColor = vec4(texel0.rgb, alpha);
}else{
discard;
}
}
alphatest.vert
=======
uniform mat4 modelViewProjectionMatrix;
attribute vec4 position;
attribute vec2 texcoord;
varying vec2 texCoordVarying;
void main()
{
texCoordVarying = texcoord;
gl_Position = modelViewProjectionMatrix * position;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment