Guest User

Untitled

a guest
Sep 20th, 2019
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="x-shader/x-fragment" id="mask">
  2. precision highp float;
  3.  
  4. uniform vec2 resolution;
  5. uniform sampler2D image;
  6. uniform vec2 imageResolution;
  7. uniform float progress;
  8.  
  9. vec2 adjustRatio(vec2 uv, vec2 inputResolution, vec2 outputResolution) {
  10. vec2 ratio = vec2(
  11. min((outputResolution.x / outputResolution.y) / (inputResolution.x / inputResolution.y), 1.),
  12. min((outputResolution.y / outputResolution.x) / (inputResolution.y / inputResolution.x), 1.)
  13. );
  14. return uv * ratio + (1. - ratio) * 0.5;
  15. }
  16.  
  17. vec2 getZoomedUv(vec2 uv, float zoom, vec2 origin) {
  18. origin.x = -origin.x;
  19. uv += origin;
  20. float scale = 1. / zoom;
  21. vec2 zoomedUv = uv * scale;
  22. zoomedUv -= 0.5 * (scale - 1.);
  23. return zoomedUv;
  24. }
  25.  
  26. const float maxMove = 0.032;
  27.  
  28. void main() {
  29. vec2 uv = gl_FragCoord.st / resolution;
  30. uv.y = 1. - uv.y;
  31. uv = adjustRatio(uv, imageResolution, resolution);
  32. uv = getZoomedUv(uv, 1. + maxMove, vec2((progress - 0.5) * maxMove, 0.));
  33.  
  34. gl_FragColor = texture2D(image, uv);
  35. }
  36. </script>
RAW Paste Data