hp_uwater.fp 643 B

123456789101112131415161718
  1. void main() {
  2. if (waterFactor > 0) {
  3. float tau = 6.28318530717958647692;
  4. vec2 texSize = textureSize(InputTexture, 0);
  5. // offset the pixel location by this amount, a sine wave to create a wobble effect
  6. vec2 waterOffset = vec2(waterFactor * sin(tau * TexCoord.y + timer * 0.05), waterFactor * sin(tau * TexCoord.x + timer * 0.05));
  7. vec2 coord = TexCoord + waterOffset;
  8. // return black if the resulting coord isn't on screen
  9. vec4 color = (coord.x > 0 && coord.x < 1 && coord.y > 0 && coord.y < 1) ?
  10. texture(InputTexture, coord) : vec4(0, 0, 0, 0);
  11. FragColor = color;
  12. }
  13. else FragColor = texture(InputTexture, TexCoord);
  14. }