invert.frag 566 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. ** Invert RGBA
  3. ** (c)2013 Marian Weger
  4. */
  5. #extension GL_ARB_texture_rectangle : enable
  6. uniform sampler2DRect tex0;
  7. uniform vec4 invert;
  8. void main(void)
  9. {
  10. vec2 pos = (gl_TextureMatrix[0] * gl_TexCoord[0]).st;
  11. vec4 color_old = texture2DRect(tex0, vec2(pos.x, pos.y));
  12. vec4 color_new = color_old;
  13. if(invert.r == 1.0)
  14. {
  15. color_new.r = 1.0 - color_old.r;
  16. }
  17. if(invert.g == 1.0)
  18. {
  19. color_new.g = 1.0 - color_old.g;
  20. }
  21. if(invert.b == 1.0)
  22. {
  23. color_new.b = 1.0 - color_old.b;
  24. }
  25. if(invert.a == 1.0)
  26. {
  27. color_new.a = 1.0 - color_old.a;
  28. }
  29. gl_FragColor = color_new;
  30. }