Guest User

inkspread.frag

a guest
Jul 20th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. #version 150
  2.  
  3. uniform sampler2DRect tex0;
  4. const float diag = 1.414213562373095;
  5.  
  6. in vec2 fragCoord;
  7. out vec4 outputColor;
  8.  
  9. uniform float T;
  10.  
  11. vec4 F(vec4 x0,vec4 x1,float dist)
  12. {
  13.     return (x1-x0)/(T*dist);
  14. }
  15.  
  16. void main()
  17. {
  18.     ivec2 ix = ivec2(fragCoord.xy);
  19.    
  20.     vec4 x11 = texelFetch(tex0, ix);
  21.     vec4 x01 = texelFetchOffset(tex0, ix, ivec2(-1, 0));
  22.     vec4 x21 = texelFetchOffset(tex0, ix, ivec2( 1, 0));
  23.     vec4 x10 = texelFetchOffset(tex0, ix, ivec2( 0,-1));
  24.     vec4 x12 = texelFetchOffset(tex0, ix, ivec2( 0, 1));
  25.     vec4 x00 = texelFetchOffset(tex0, ix, ivec2(-1,-1));
  26.     vec4 x02 = texelFetchOffset(tex0, ix, ivec2(-1, 1));
  27.     vec4 x20 = texelFetchOffset(tex0, ix, ivec2( 1,-1));
  28.     vec4 x22 = texelFetchOffset(tex0, ix, ivec2( 1, 1));
  29.     vec4 d01 = F(x11,x01,1.0);
  30.     vec4 d21 = F(x11,x21,1.0);
  31.     vec4 d10 = F(x11,x10,1.0);
  32.     vec4 d12 = F(x11,x12,1.0);
  33.     vec4 d00 = F(x11,x00,diag);
  34.     vec4 d02 = F(x11,x02,diag);
  35.     vec4 d20 = F(x11,x20,diag);
  36.     vec4 d22 = F(x11,x22,diag);
  37.     vec4 res = x11+d01+d21+d10+d12+d00+d02+d20+d22;
  38.    
  39.     vec4 color = texture(tex0,fragCoord);
  40.     outputColor = vec4(res.rgb,1.0);
  41. }
Add Comment
Please, Sign In to add comment