wave.fs 884 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0;
  7. uniform vec4 colDiffuse;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. uniform float seconds;
  11. uniform vec2 size;
  12. uniform float freqX;
  13. uniform float freqY;
  14. uniform float ampX;
  15. uniform float ampY;
  16. uniform float speedX;
  17. uniform float speedY;
  18. void main() {
  19. float pixelWidth = 1.0/size.x;
  20. float pixelHeight = 1.0/size.y;
  21. float aspect = pixelHeight/pixelWidth;
  22. float boxLeft = 0.0;
  23. float boxTop = 0.0;
  24. vec2 p = fragTexCoord;
  25. p.x += cos((fragTexCoord.y - boxTop)*freqX/(pixelWidth*750.0) + (seconds*speedX))*ampX*pixelWidth;
  26. p.y += sin((fragTexCoord.x - boxLeft)*freqY*aspect/(pixelHeight*750.0) + (seconds*speedY))*ampY*pixelHeight;
  27. finalColor = texture(texture0, p)*colDiffuse*fragColor;
  28. }