wiggle.frag 618B

123456789101112131415161718192021
  1. #version 120
  2. uniform sampler2D texture;
  3. uniform vec2 screenSize;
  4. uniform float time;
  5. varying vec2 uvCoord;
  6. void main()
  7. {
  8. // Higher strength means bigger wobble
  9. float strength = 10;
  10. float flatness = 4;
  11. // Higher speed means faster wobble
  12. float speed = 2;
  13. float variation = cos(time);
  14. float x = uvCoord.x + (sin( time*speed + uvCoord.y/flatness * screenSize.y/strength ) + 0.5)/screenSize.x*strength;
  15. float y = uvCoord.y + variation*(cos( time*speed + uvCoord.x/flatness * screenSize.x/strength ) + 0.5)/screenSize.y*strength;
  16. gl_FragColor = texture2D( texture, vec2( x, y ) );
  17. }