You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
750 B

  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0;
  7. uniform vec4 fragTintColor;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. // NOTE: Add here your custom variables
  11. void main()
  12. {
  13. // Texel color fetching from texture sampler
  14. vec3 texelColor = texture(texture0, fragTexCoord).rgb;
  15. vec3 colors[3];
  16. colors[0] = vec3(0.0, 0.0, 1.0);
  17. colors[1] = vec3(1.0, 1.0, 0.0);
  18. colors[2] = vec3(1.0, 0.0, 0.0);
  19. float lum = (texelColor.r + texelColor.g + texelColor.b)/3.0;
  20. int ix = (lum < 0.5)? 0:1;
  21. vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5);
  22. finalColor = vec4(tc, 1.0);
  23. }