blur1.frag 1.7KB

12345678910111213141516171819202122232425262728293031323334
  1. #version 120
  2. uniform sampler2D texture;
  3. uniform sampler2D desktop;
  4. uniform vec2 screenSize;
  5. varying vec2 uvCoord;
  6. // Stolen from https://github.com/Jam3/glsl-fast-gaussian-blur kinda
  7. void main()
  8. {
  9. float radius = 1;
  10. vec2 upsideDownUV = vec2( uvCoord.x, -uvCoord.y );
  11. vec4 color = vec4(0.0);
  12. vec2 off1 = vec2(1.411764705882353) * vec2( radius, 0 );
  13. vec2 off2 = vec2(3.2941176470588234) * vec2( radius, 0 );
  14. vec2 off3 = vec2(5.176470588235294) * vec2( radius, 0 );
  15. color += texture2D(desktop, upsideDownUV) * 0.1964825501511404;
  16. color += texture2D(desktop, upsideDownUV + (off1 / screenSize)) * 0.2969069646728344;
  17. color += texture2D(desktop, upsideDownUV - (off1 / screenSize)) * 0.2969069646728344;
  18. color += texture2D(desktop, upsideDownUV + (off2 / screenSize)) * 0.09447039785044732;
  19. color += texture2D(desktop, upsideDownUV - (off2 / screenSize)) * 0.09447039785044732;
  20. color += texture2D(desktop, upsideDownUV + (off3 / screenSize)) * 0.010381362401148057;
  21. color += texture2D(desktop, upsideDownUV - (off3 / screenSize)) * 0.010381362401148057;
  22. vec4 tcolor = vec4(0.0);
  23. tcolor += texture2D(texture, uvCoord) * 0.1964825501511404;
  24. tcolor += texture2D(texture, uvCoord + (off1 / screenSize)) * 0.2969069646728344;
  25. tcolor += texture2D(texture, uvCoord - (off1 / screenSize)) * 0.2969069646728344;
  26. tcolor += texture2D(texture, uvCoord + (off2 / screenSize)) * 0.09447039785044732;
  27. tcolor += texture2D(texture, uvCoord - (off2 / screenSize)) * 0.09447039785044732;
  28. tcolor += texture2D(texture, uvCoord + (off3 / screenSize)) * 0.010381362401148057;
  29. tcolor += texture2D(texture, uvCoord - (off3 / screenSize)) * 0.010381362401148057;
  30. gl_FragColor = (tcolor * color);
  31. }