wiggle.frag 588B

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