Guest User

Untitled

a guest
Aug 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform float time;         // time in seconds
  2. uniform float speed;        // the speed in the range of 0 - 1
  3. uniform vec2 amplitude;     // amplitude of x and y wave
  4. uniform vec2 waves;     // the number of waves
  5. uniform vec2 texsize;       // size of the texture
  6. uniform sampler2D tex0;     // the texture we apply the shader on
  7.  
  8. const float pi = 3.14159;
  9.  
  10. void main(void) {
  11.  
  12.     // getting the current uv coordinates
  13.     vec2 uv = gl_TexCoord[0].xy;   
  14.    
  15.     // holding a temp vector of the current fragment
  16.     vec2 temp = vec2(uv.x, uv.y);
  17.    
  18.     float angularFre;
  19.    
  20.     if(waves.x > 0.0) {
  21.         angularFre = 2.0 * pi * waves.x;
  22.         uv.x += sin(temp.y * angularFre  + (time * (speed * 10.0))) * (amplitude.x / texsize.x) * 10.0;
  23.        
  24.     }
  25.     if(waves.y > 0.0) {
  26.         angularFre = 2.0 * pi * waves.y;
  27.         uv.y += sin(temp.x * angularFre  + (time * (speed * 10.0))) * (amplitude.y / texsize.y) * 10.0;
  28.     }
  29.    
  30.     if(uv.x < 0.0 || uv.x > 1.) {
  31.         discard;
  32.     }
  33.     if(uv.y < 0.0 || uv.y > 1.) {
  34.         discard;
  35.     }
  36.  
  37.     vec4 color = texture2D(tex0, uv);
  38.     gl_FragColor = color;
  39. }
Add Comment
Please, Sign In to add comment