Last active
August 29, 2015 14:22
-
-
Save veeneck/f8601f819b5f1ac9c52e to your computer and use it in GitHub Desktop.
Detecting alpha values in a shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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