/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl

https://bitbucket.org/lindenlab/viewer-beta/ · GLSL · 51 lines · 15 code · 9 blank · 27 comment · 0 complexity · 3b60b0523e1235c35bac2cc13896e4b2 MD5 · raw file

  1. /**
  2. * @file colorFilterF.glsl
  3. *
  4. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2007, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. uniform sampler2DRect RenderTexture;
  26. uniform float brightness;
  27. uniform float contrast;
  28. uniform vec3 contrastBase;
  29. uniform float saturation;
  30. uniform vec3 lumWeights;
  31. const float gamma = 2.0;
  32. void main(void)
  33. {
  34. vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
  35. /// Modulate brightness
  36. color *= brightness;
  37. /// Modulate contrast
  38. color = mix(contrastBase, color, contrast);
  39. /// Modulate saturation
  40. color = mix(vec3(dot(color, lumWeights)), color, saturation);
  41. gl_FragColor = vec4(color, 1.0);
  42. }