gamma.fs 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #version 150
  2. uniform sampler2D source[];
  3. in Vertex {
  4. vec2 texCoord;
  5. };
  6. out vec4 fragColor;
  7. #define saturation 1.0
  8. #define luminance 1.00
  9. #define gamma vec3(1.7)
  10. vec3 desaturate(vec3 col)
  11. {
  12. return vec3(dot(col, vec3(0.2126, 0.7152, 0.0722)));
  13. }
  14. void main() {
  15. //combine
  16. // the LUT average color is vec3 (0.498,0.572,0.644)
  17. // multiplying it with sum will compensate for running the gaussian pass on the original texture instead
  18. // of running it on the output of shadhow-mask.fs
  19. // had to use 0.528 for red instead of 0.498 , not sure why
  20. vec3 image = texture(source[1], texCoord).rgb*vec3 (0.528,0.572,0.644);
  21. vec3 previous = texture(source[0], texCoord).rgb;
  22. vec3 res = 1.0 - (1.0 - image) * (1.0 - image) * (1.0 - previous);
  23. //compensate for the missing gaussian-scanline.fs pass
  24. res*=1.05;
  25. res = mix(desaturate(res), res, saturation);
  26. res = pow(res, gamma);
  27. res *= luminance;
  28. fragColor = vec4(res , 1.0);
  29. }