ripple.frag 528 B

1234567891011121314151617181920212223
  1. // Applies sinc function to the user texture.
  2. // Stolen from http://adrianboeing.blogspot.com/2011/02/ripple-effect-in-webgl.html
  3. #version 330
  4. precision mediump float;
  5. uniform vec2 resolution;
  6. uniform float time;
  7. uniform vec2 mouse;
  8. uniform sampler2D tex;
  9. in vec2 uv;
  10. in vec4 color;
  11. out vec4 out_color;
  12. void main(void) {
  13. vec2 cPos = 2.0*uv - 1.0;
  14. float cLength = length(cPos);
  15. vec2 tex_uv = uv + (cPos/cLength)*mix(cos(cLength*12.0-time*4.0)*0.03, 0.0, cLength / 0.25);
  16. out_color = texture(tex, tex_uv);
  17. }