gaussian-horiz.fs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #version 150
  2. uniform sampler2D source[];
  3. uniform vec2 targetSize;
  4. uniform vec4 sourceSize[];
  5. in Vertex {
  6. vec2 texCoord;
  7. };
  8. out vec4 fragColor;
  9. #define CRTgamma 2.5
  10. #define display_gamma 2.2
  11. #define TEX2D(c) pow(texture2D(source[0],(c)),vec4(CRTgamma))
  12. void main()
  13. {
  14. vec2 xy = texCoord;
  15. float oney = 1.0 / sourceSize[0].y;
  16. float wid = 6.0;
  17. float c1 = exp(-1.0/wid/wid);
  18. float c2 = exp(-4.0/wid/wid);
  19. float c3 = exp(-9.0/wid/wid);
  20. float c4 = exp(-16.0/wid/wid);
  21. float norm = 1.0 / (1.0 + 2.0*(c1+c2+c3+c4));
  22. vec4 sum = vec4(0.0);
  23. sum += TEX2D(xy + vec2(0.0, -2.0 * oney)) * vec4(c4);
  24. sum += TEX2D(xy + vec2(0.0, -1.5 * oney)) * vec4(c3);
  25. sum += TEX2D(xy + vec2(0.0, -1.0 * oney)) * vec4(c2);
  26. sum += TEX2D(xy + vec2(0.0, -0.5 * oney)) * vec4(c1);
  27. sum += TEX2D(xy);
  28. sum += TEX2D(xy + vec2(0.0, 0.5 * oney)) * vec4(c1);
  29. sum += TEX2D(xy + vec2(0.0, 1.0 * oney)) * vec4(c2);
  30. sum += TEX2D(xy + vec2(0.0, 1.5 * oney)) * vec4(c3);
  31. sum += TEX2D(xy + vec2(0.0, 2.0 * oney)) * vec4(c4);
  32. fragColor = pow(sum*vec4(norm),vec4(1.0/display_gamma));
  33. }