Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform float time; // time in seconds
- uniform float speed; // the speed in the range of 0 - 1
- uniform vec2 amplitude; // amplitude of x and y wave
- uniform vec2 waves; // the number of waves
- uniform vec2 texsize; // size of the texture
- uniform sampler2D tex0; // the texture we apply the shader on
- const float pi = 3.14159;
- void main(void) {
- // getting the current uv coordinates
- vec2 uv = gl_TexCoord[0].xy;
- // holding a temp vector of the current fragment
- vec2 temp = vec2(uv.x, uv.y);
- float angularFre;
- if(waves.x > 0.0) {
- angularFre = 2.0 * pi * waves.x;
- uv.x += sin(temp.y * angularFre + (time * (speed * 10.0))) * (amplitude.x / texsize.x) * 10.0;
- }
- if(waves.y > 0.0) {
- angularFre = 2.0 * pi * waves.y;
- uv.y += sin(temp.x * angularFre + (time * (speed * 10.0))) * (amplitude.y / texsize.y) * 10.0;
- }
- if(uv.x < 0.0 || uv.x > 1.) {
- discard;
- }
- if(uv.y < 0.0 || uv.y > 1.) {
- discard;
- }
- vec4 color = texture2D(tex0, uv);
- gl_FragColor = color;
- }
Add Comment
Please, Sign In to add comment