underwater.fp 538 B

123456789101112131415161718192021222324
  1. // https://www.shadertoy.com/view/Mls3DH
  2. const float speed = 0.0035;
  3. const float frequency = 8.0;
  4. vec2 shift(vec2 p)
  5. {
  6. float d = timer * speed;
  7. vec2 f = frequency * (p + d);
  8. vec2 q = cos(vec2(cos(f.x - f.y) * cos(f.y), sin(f.x + f.y) * sin(f.y)));
  9. return q;
  10. }
  11. void main(void)
  12. {
  13. vec2 texSize = vec2(textureSize(InputTexture, 0));
  14. vec2 r = TexCoord;
  15. vec2 p = shift(r);
  16. vec2 q = shift(r + 1.0);
  17. float amplitude = (texSize.x * 0.025) / texSize.x;
  18. vec2 s = r + amplitude * (p - q);
  19. FragColor = vec4(texture(InputTexture, s));
  20. }