beam4-p1.fs 1.1 KB

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