Advertisement
Guest User

Untitled

a guest
May 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform sampler2D texture;
  2. uniform float x;
  3. uniform float y;
  4. uniform float time;
  5.  
  6. void main()
  7. {
  8.     vec3 clr = vec3(texture2D(texture, gl_TexCoord[0].st));
  9.     float distx = abs(x-gl_TexCoord[0].st[0]);
  10.     float disty = abs(y-gl_TexCoord[0].st[1]);
  11.     float dist = sqrt(distx*distx + disty*disty);
  12.     float bw = 0.3*clr[0] + 0.59*clr[1] + 0.11*clr[2];
  13.    
  14.  
  15.           vec4 sum = vec4(0.0);
  16.           float blurSize = 0.00195*dist;
  17.    
  18.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] - 4.0*blurSize, gl_TexCoord[0].st[1])) * 0.05;
  19.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] - 3.0*blurSize, gl_TexCoord[0].st[1])) * 0.09;
  20.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] - 2.0*blurSize, gl_TexCoord[0].st[1])) * 0.12;
  21.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] - blurSize, gl_TexCoord[0].st[1])) * 0.15;
  22.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0], gl_TexCoord[0].st[1])) * 0.16;
  23.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] + blurSize, gl_TexCoord[0].st[1])) * 0.15;
  24.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] + 2.0*blurSize, gl_TexCoord[0].st[1])) * 0.12;
  25.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] + 3.0*blurSize, gl_TexCoord[0].st[1])) * 0.09;
  26.    sum += texture2D(texture, vec2(gl_TexCoord[0].st[0] + 4.0*blurSize, gl_TexCoord[0].st[1])) * 0.05;
  27.  
  28.    gl_FragColor[0] = sum[0] + dist*(bw - clr[0]);
  29.       gl_FragColor[1] = sum[1] + dist*(bw - clr[1]);
  30.     gl_FragColor[2] = sum[2] + dist*(bw - clr[2]);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement