zstencil.vert.0.glsl100es 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #version 100
  2. struct m3x2
  3. {
  4. vec3 r0;
  5. vec3 r1;
  6. };
  7. struct Block
  8. {
  9. vec4 transform;
  10. vec2 pathOffset;
  11. };
  12. uniform Block _block;
  13. attribute vec2 from;
  14. attribute vec2 ctrl;
  15. attribute vec2 to;
  16. attribute float maxy;
  17. attribute float corner;
  18. varying vec2 vFrom;
  19. varying vec2 vCtrl;
  20. varying vec2 vTo;
  21. vec3 transform3x2(m3x2 t, vec3 v)
  22. {
  23. return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v));
  24. }
  25. void main()
  26. {
  27. vec2 from_1 = from + _block.pathOffset;
  28. vec2 ctrl_1 = ctrl + _block.pathOffset;
  29. vec2 to_1 = to + _block.pathOffset;
  30. float maxy_1 = maxy + _block.pathOffset.y;
  31. float c = corner;
  32. vec2 pos;
  33. if (c >= 0.375)
  34. {
  35. c -= 0.5;
  36. pos.y = maxy_1 + 1.0;
  37. }
  38. else
  39. {
  40. pos.y = min(min(from_1.y, ctrl_1.y), to_1.y) - 1.0;
  41. }
  42. if (c >= 0.125)
  43. {
  44. pos.x = max(max(from_1.x, ctrl_1.x), to_1.x) + 1.0;
  45. }
  46. else
  47. {
  48. pos.x = min(min(from_1.x, ctrl_1.x), to_1.x) - 1.0;
  49. }
  50. vFrom = from_1 - pos;
  51. vCtrl = ctrl_1 - pos;
  52. vTo = to_1 - pos;
  53. pos = (pos * _block.transform.xy) + _block.transform.zw;
  54. m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0));
  55. vec3 param_1 = vec3(pos, 0.0);
  56. gl_Position = vec4(transform3x2(param, param_1), 1.0);
  57. }