Guest User

Untitled

a guest
Aug 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. uniform sampler2D tex;
  3. uniform float time = 0.0;
  4.  
  5. uniform float width = 240;
  6. uniform float height = 240;
  7. float sum = 1.0/442.0;
  8. float weights[4] = float[](70.0, 56.0, 28.0, 8.0, 1.0);
  9. float offsets[4] = float[](0, 1, 2, 3, 4);
  10.  
  11. /*
  12. input unnormalised values.
  13. returns pixel value of the pixel dx and dy relatively to the processed one
  14. */
  15. vec4 getPixel(float dx, float dy)
  16. {
  17.     return  texture2D(tex, gl_TexCoord[0].st + vec2(dx/width, dy/height));
  18. }
  19.  
  20. void main()
  21. {
  22.     /*
  23.         -1 -1 -1
  24.         -1  8 -1
  25.         -1 -1 -1
  26.     */
  27.     vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
  28.  
  29.     for(int i=1; i<=4; i++){
  30.         color += getPixel(0, offsets[i])*weight[i]*sum;
  31.         color += getPixel(0, -offsets[i])*weight[i]*sum;
  32.         color += getPixel(offsets[i], 0)*weight[i]*sum;
  33.         color += getPixel(-offsets[i], 0)*weight[i]*sum;
  34.     }
  35.     color += getPixel(0, 0)*weight[0]*sum;
  36.     gl_FragColor = color;
  37. }
Add Comment
Please, Sign In to add comment