hippie.frag 854B

123456789101112131415161718192021222324252627282930
  1. #version 120
  2. uniform sampler2D texture;
  3. uniform sampler2D desktop;
  4. uniform int desktopWidth;
  5. uniform int desktopHeight;
  6. uniform float time;
  7. varying vec2 uvCoord;
  8. const float pi = 3.14159265f;
  9. vec3 color(float x) {
  10. return max(min(sin(vec3(x,x+pi*2.0/3.0,x+pi*4.0/3.0))+0.5,1.0),0.0);
  11. }
  12. void main() {
  13. vec2 resolution = vec2( desktopWidth, desktopHeight );
  14. vec2 pos = (( gl_FragCoord.xy / resolution.xy )-0.5)*resolution.xy/resolution.x*4.0;
  15. pos+=normalize(pos);
  16. pos.xy+=sin(pos.yx*10.0)*0.1;
  17. float r=(2.0/(dot(pos,pos)*10.0+1.0));
  18. vec2 rr=vec2(cos(r),sin(r));
  19. pos=pos.xy*rr.xx+pos.yx*rr.yy*vec2(-1.0,1.0);
  20. float f=(length(pos)*10.0)+time;
  21. //f=acos((pos.x/length(pos)*0.5+0.5)*pi);
  22. f+=sin(atan(pos.y,pos.x)*7.0)*5.0;
  23. float alpha = texture2D(texture,uvCoord).a;
  24. gl_FragColor = vec4(color(f),alpha);
  25. }