ev_pro_33.vert 2.0 KB

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