Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save veeneck/f8601f819b5f1ac9c52e to your computer and use it in GitHub Desktop.

Select an option

Save veeneck/f8601f819b5f1ac9c52e to your computer and use it in GitHub Desktop.
Detecting alpha values in a shader
void main() {
// Find the pixel at the coordinate of the actual texture
vec4 val = texture2D(u_texture, v_tex_coord);
// If the alpha value of that pixel is 0.0
if (val.a == 0.0) {
// Turn the pixel green
gl_FragColor = vec4(0.0,1.0,0.0,1.0);
} else {
// Otherwise, keep the original color
gl_FragColor = val;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment