Last active
August 29, 2015 14:22
-
-
Save veeneck/23854616813f74819d66 to your computer and use it in GitHub Desktop.
Gradient and masking shader
This file contains 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() { | |
// Load the pixel from our original texture, and the same place in the gradient circle | |
vec4 val = texture2D(u_texture, v_tex_coord); | |
vec4 grad = texture2D(u_gradient, v_tex_coord); | |
// [1 - ORIGINAL CHECK] If the original is transparent AND | |
// [2 - HEALTH CHECK] The gradient image has a black value less than the remaining health AND | |
// [3 - MASKING] The gradient pixel is not transparent | |
if (val.a < 0.1 && grad.r < u_health && grad.a > 0.8) { | |
gl_FragColor = vec4(0.0,1.0,0.0,1.0); | |
} else { | |
gl_FragColor = val; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment