Advertisement
Guest User

Untitled

a guest
Mar 29th, 2012
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. //VERTEX
  2. #ifdef GL_ES
  3. #define MED mediump
  4. #else
  5. #define MED
  6. #endif
  7.  
  8. attribute vec4 a_position;
  9. attribute vec2 a_texCoord0;
  10. uniform vec2 dir;
  11. uniform vec2 size;
  12. varying MED vec2 v_texCoords0;
  13. varying MED vec2 v_texCoords1;
  14. varying MED vec2 v_texCoords2;
  15. varying MED vec2 v_texCoords3;
  16. varying MED vec2 v_texCoords4;
  17. const vec2 futher = vec2(3.2307692308, 3.2307692308);
  18. const vec2 closer = vec2(1.3846153846, 1.3846153846);
  19. void main()
  20. {
  21.     vec2 sizeAndDir = dir / size;
  22.     vec2 f = futher * sizeAndDir;
  23.     vec2 c = closer * sizeAndDir;
  24.    
  25.     v_texCoords0 = a_texCoord0 - f;
  26.     v_texCoords1 = a_texCoord0 - c;
  27.     v_texCoords2 = a_texCoord0;
  28.     v_texCoords3 = a_texCoord0 + c;
  29.     v_texCoords4 = a_texCoord0 + f;
  30.    
  31.     gl_Position = a_position;
  32. }
  33.  
  34. //FRAGMENT
  35. #ifdef GL_ES
  36. #define MED mediump
  37. precision mediump float; //change to lowp to get blazing fast shader but with some glitches may occur
  38. #else
  39. #define MED
  40. #endif
  41.  
  42. uniform sampler2D u_texture;
  43. varying MED vec2 v_texCoords0;
  44. varying MED vec2 v_texCoords1;
  45. varying MED vec2 v_texCoords2;
  46. varying MED vec2 v_texCoords3;
  47. varying MED vec2 v_texCoords4;
  48. const float center = 0.2270270270;
  49. const float close = 0.3162162162;
  50. const float far = 0.0702702703;
  51. void main()
  52. {    
  53.    gl_FragColor.rgb = far * texture2D(u_texture, v_texCoords0).rgb
  54.                 + close * texture2D(u_texture, v_texCoords1).rgb
  55.                 + center * texture2D(u_texture, v_texCoords2).rgb
  56.                 + close * texture2D(u_texture, v_texCoords3).rgb
  57.                 + far * texture2D(u_texture, v_texCoords4).rgb;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement