ev_pro_22.vert 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // (c)2011-2012 Cyrille Henry & Marian Weger
  2. // part of EXTENDED VIEW TOOLKIT // gpl v3
  3. uniform vec2 Vtl,Vbl,Vtr,Vbr; // Vertex position
  4. uniform vec2 Ttl,Tbl,Ttr,Tbr; // texture coordinate
  5. uniform vec2 weight;
  6. varying vec2 pos;
  7. //vec2 _mix(vec2 A,vec2 B,float K)
  8. //{
  9. // return(B*K+(1.-K)*A);
  10. //}
  11. void main()
  12. {
  13. gl_TexCoord[0] = gl_MultiTexCoord0;
  14. vec4 position = gl_Vertex;
  15. // vec4 position = gl_TexCoord[0];
  16. // position.x /= 1024.;
  17. // position.y /= 768.;
  18. // position.xy *= 2.;
  19. // position.xy -= 1.;
  20. pos = (gl_Vertex.xy+vec2(1.))/2.;
  21. vec2 tex_position = position.xy;
  22. tex_position.x = (tex_position.x+1.)/2.;
  23. tex_position.y = (tex_position.y+1.)/2.;
  24. if (weight.x >= 0.)
  25. {
  26. tex_position.x = (tex_position.x - (weight.x * tex_position.x)) / (1. - (weight.x * tex_position.x));
  27. }
  28. else
  29. {
  30. tex_position.x = 1. - (((1. - tex_position.x) + (weight.x * (1. - tex_position.x))) / (1. + (weight.x * (1. - tex_position.x))));
  31. }
  32. if (weight.y <= 0.)
  33. {
  34. tex_position.y = (tex_position.y + (weight.y * tex_position.y)) / (1. + (weight.y * tex_position.y));
  35. }
  36. else
  37. {
  38. tex_position.y = 1. - (((1. - tex_position.y) - (weight.y * (1. - tex_position.y))) / (1. - (weight.y * (1. - tex_position.y))));
  39. }
  40. vec2 tex_top = mix(Ttl,Ttr,tex_position.x);
  41. vec2 tex_bottom = mix(Tbl,Tbr,tex_position.x);
  42. gl_TexCoord[0].st = mix(tex_top,tex_bottom, tex_position.y);
  43. vec2 pos_top = mix(Vtl,Vtr,(position.x+1.)/2.);
  44. vec2 pos_bottom = mix(Vbl,Vbr,(position.x+1.)/2.);
  45. position.xy = mix(pos_top,pos_bottom, (position.y+1.)/2.);
  46. gl_Position = gl_ModelViewProjectionMatrix * position;
  47. }