grey_shader@alpha.fsh 526 B

1234567891011121314151617181920
  1. #ifdef GL_ES
  2. precision lowp float;
  3. #endif
  4. varying vec4 v_fragmentColor;
  5. varying vec2 v_texCoord;
  6. void main()
  7. {
  8. vec4 texColor = texture2D(CC_Texture0, v_texCoord);
  9. texColor.a = texture2D(CC_Texture1, v_texCoord).r;
  10. texColor.rgb *= texColor.a; // premultiply alpha channel
  11. texColor = v_fragmentColor * texColor;
  12. float grey = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
  13. float alpha = v_fragmentColor.a;
  14. gl_FragColor = vec4(grey * alpha, grey * alpha, grey * alpha, texColor.a * alpha);
  15. }