Advertisement
atm959

waterFragment.glsl

Aug 6th, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #version 330 core
  2. out vec4 FragColor;
  3.  
  4. in vec2 TexCoord;
  5.  
  6. uniform sampler2D ourTexture;
  7. uniform sampler2D dudvMap;
  8. uniform float time;
  9. uniform float width;
  10. uniform float height;
  11.  
  12. void main() {
  13. /*
  14. vec4 dudvCol = texture(dudvMap, vec2(TexCoord.x + time, -TexCoord.y + time));
  15. vec4 dudvCol2 = texture(dudvMap, vec2(TexCoord.x + time, -TexCoord.y));
  16. vec4 finalDudv = mix(dudvCol, dudvCol2, 0.5);
  17.  
  18. vec2 distortion = vec2((finalDudv.r * 2) - 1, (finalDudv.g * 2) - 1) * 0.01;
  19.  
  20. vec2 newTexCoord = vec2(clamp(TexCoord.x + distortion.x, 0, 1), clamp(TexCoord.y + distortion.y, 0, 1));
  21.  
  22. vec4 texCol = texture(ourTexture, vec2(newTexCoord.x, -newTexCoord.y));
  23.  
  24. FragColor = texCol;
  25. */
  26.  
  27. vec4 texCol1 = texture(ourTexture, vec2(TexCoord.x + (0.05 * sin((time * 10) + (-TexCoord.y * 10))), -TexCoord.y));
  28. vec4 texCol2 = texture(ourTexture, vec2(TexCoord.x, -TexCoord.y + (0.05 * cos((time * 10) + (TexCoord.x * 10)))));
  29.  
  30. FragColor = texCol1 * texCol2;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement