GaussianBlur1D.js 1012 B

123456789101112131415161718192021222324252627282930313233343536
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "#define SAMPLES 8\n\
  3. uniform float delta;\n\
  4. uniform float sigma;\n\
  5. uniform float direction;\n\
  6. uniform sampler2D colorTexture;\n\
  7. #ifdef USE_STEP_SIZE\n\
  8. uniform float stepSize;\n\
  9. #else\n\
  10. uniform vec2 step;\n\
  11. #endif\n\
  12. varying vec2 v_textureCoordinates;\n\
  13. void main()\n\
  14. {\n\
  15. vec2 st = v_textureCoordinates;\n\
  16. vec2 dir = vec2(1.0 - direction, direction);\n\
  17. #ifdef USE_STEP_SIZE\n\
  18. vec2 step = vec2(stepSize * (czm_pixelRatio / czm_viewport.zw));\n\
  19. #else\n\
  20. vec2 step = step;\n\
  21. #endif\n\
  22. vec3 g;\n\
  23. g.x = 1.0 / (sqrt(czm_twoPi) * sigma);\n\
  24. g.y = exp((-0.5 * delta * delta) / (sigma * sigma));\n\
  25. g.z = g.y * g.y;\n\
  26. vec4 result = texture2D(colorTexture, st) * g.x;\n\
  27. for (int i = 1; i < SAMPLES; ++i)\n\
  28. {\n\
  29. g.xy *= g.yz;\n\
  30. vec2 offset = float(i) * dir * step;\n\
  31. result += texture2D(colorTexture, st - offset) * g.x;\n\
  32. result += texture2D(colorTexture, st + offset) * g.x;\n\
  33. }\n\
  34. gl_FragColor = result;\n\
  35. }\n\
  36. ";