gaussian-horiz.fs 1.1 KB

12345678910111213141516171819202122232425262728293031
  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 SHARPNESS (8.0 / (sourceSize[0].x / 512.0))
  10. void main()
  11. {
  12. vec4 sum = vec4(0.0);
  13. sum += texture(source[0], vec2(texCoord.x - 4.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.05;
  14. sum += texture(source[0], vec2(texCoord.x - 3.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.09;
  15. sum += texture(source[0], vec2(texCoord.x - 2.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.12;
  16. sum += texture(source[0], vec2(texCoord.x - 1.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.15;
  17. sum += texture(source[0], vec2(texCoord.x, texCoord.y)) * 0.16;
  18. sum += texture(source[0], vec2(texCoord.x + 1.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.15;
  19. sum += texture(source[0], vec2(texCoord.x + 2.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.12;
  20. sum += texture(source[0], vec2(texCoord.x + 3.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.09;
  21. sum += texture(source[0], vec2(texCoord.x + 4.0 / (SHARPNESS * 128.0), texCoord.y)) * 0.05;
  22. fragColor = sum;
  23. }