I found an underwater (distort) effect and I got it to work but somehow I cannot make it animate given the offset here:

Fragment Shader code:

uniform sampler2D fbo_texture;
uniform float offset;
varying vec2 f_texcoord;

void main(void) {
  vec2 texcoord = f_texcoord;
  texcoord.x += sin(texcoord.y * 4*2*3.14159 + offset) / 100;
  gl_FragColor = texture2D(fbo_texture, texcoord);

Original Source here


Figured it out by looking other shader examples and hopefully it will benefit others. elapsedTime can be added to the computation or offset and will animate the effect, some use sin/cos as well..

uniform float elapsedTime;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.