grayscale.fs 408 B

1234567891011121314151617181920
  1. #version 330
  2. in vec2 fragTexCoord;
  3. out vec4 fragColor;
  4. uniform sampler2D texture0;
  5. uniform vec4 tintColor;
  6. // NOTE: Add here your custom variables
  7. void main()
  8. {
  9. vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
  10. // Convert to grayscale using NTSC conversion weights
  11. float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
  12. fragColor = vec4(gray, gray, gray, tintColor.a);
  13. }