暂无描述

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (binding = 0) uniform sampler2D samplerColor0;
  5. layout (binding = 1) uniform sampler2D samplerColor1;
  6. layout (location = 0) in vec2 inUV;
  7. layout (location = 0) out vec4 outColor;
  8. layout (constant_id = 0) const int dir = 0;
  9. void main(void)
  10. {
  11. // From the OpenGL Super bible
  12. const float weights[] = float[](0.0024499299678342,
  13. 0.0043538453346397,
  14. 0.0073599963704157,
  15. 0.0118349786570722,
  16. 0.0181026699707781,
  17. 0.0263392293891488,
  18. 0.0364543006660986,
  19. 0.0479932050577658,
  20. 0.0601029809166942,
  21. 0.0715974486241365,
  22. 0.0811305381519717,
  23. 0.0874493212267511,
  24. 0.0896631113333857,
  25. 0.0874493212267511,
  26. 0.0811305381519717,
  27. 0.0715974486241365,
  28. 0.0601029809166942,
  29. 0.0479932050577658,
  30. 0.0364543006660986,
  31. 0.0263392293891488,
  32. 0.0181026699707781,
  33. 0.0118349786570722,
  34. 0.0073599963704157,
  35. 0.0043538453346397,
  36. 0.0024499299678342);
  37. const float blurScale = 0.003;
  38. const float blurStrength = 1.0;
  39. float ar = 1.0;
  40. // Aspect ratio for vertical blur pass
  41. if (dir == 1)
  42. {
  43. vec2 ts = textureSize(samplerColor1, 0);
  44. ar = ts.y / ts.x;
  45. }
  46. vec2 P = inUV.yx - vec2(0, (weights.length() >> 1) * ar * blurScale);
  47. vec4 color = vec4(0.0);
  48. for (int i = 0; i < weights.length(); i++)
  49. {
  50. vec2 dv = vec2(0.0, i * blurScale) * ar;
  51. color += texture(samplerColor1, P + dv) * weights[i] * blurStrength;
  52. }
  53. outColor = color;
  54. }