ev_360.frag 857 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Cyrille Henry 2011
  2. // modifications by Peter Venus & Marian Weger 2012
  3. // #extension GL_ARB_texture_rectangle : enable
  4. // uniform sampler2DRect MyTex;
  5. uniform sampler2D MyTex;
  6. uniform float Cx,Cy,rot, Width, Max, Min, Size;
  7. void main (void)
  8. {
  9. // calculate next power of two image size
  10. float i = 0.;
  11. float number = 0.;
  12. for(i=0.;i<24.;i++)
  13. {
  14. if(pow(2., i)>Size)
  15. {
  16. number=pow(2., i);
  17. break;
  18. }
  19. }
  20. float factor = Size / number;
  21. vec2 car_position = (gl_TextureMatrix[0] * gl_TexCoord[0]).st;
  22. float pol_r = (factor*Min) + (car_position.y * (Max - Min));
  23. float pol_theta = ((car_position.x * (Width / factor)) + rot) * 3.1415926536 / 180.;
  24. //
  25. vec2 new_car;
  26. //
  27. new_car.x = cos(pol_theta);
  28. new_car.y = sin(pol_theta);
  29. //
  30. new_car *= pol_r/2.;
  31. //
  32. new_car += factor * vec2(Cx, Cy);
  33. vec4 color = texture2D(MyTex, new_car);
  34. gl_FragColor = color;
  35. }