Advertisement
Guest User

Untitled

a guest
Aug 19th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. shader_type canvas_item;
  2.  
  3. uniform float SAMPLES = 11.0;
  4. const float WIDTH = 0.04734573810584494679397346954847;
  5.  
  6. uniform vec2 blur_scale = vec2(5, 0);
  7.  
  8. float gaussian(float x) {
  9. float x_squared = x*x;
  10.  
  11. return WIDTH * exp((x_squared / (2.0 * SAMPLES)) * -1.0);
  12. }
  13.  
  14. void fragment() {
  15. vec2 scale = TEXTURE_PIXEL_SIZE * blur_scale;
  16.  
  17. float weight = 0.0;
  18. float total_weight = 0.0;
  19. vec4 color = vec4(0.0);
  20.  
  21. for(int i=-int(SAMPLES)/2; i < int(SAMPLES)/2; ++i) {
  22. weight = gaussian(float(i));
  23. color.rgb += texture(SCREEN_TEXTURE, SCREEN_UV + scale * vec2(float(i))).rgb * weight;
  24. total_weight += weight;
  25. }
  26.  
  27. COLOR.rgb = color.rgb / total_weight;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement