Advertisement
Tkap1

Untitled

Mar 4th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. layout (location = 0) in vec2 start;
  2. layout (location = 1) in vec2 end;
  3. layout (location = 2) in float z;
  4. layout (location = 3) in vec4 color;
  5. layout (location = 4) in float width;
  6.  
  7. out vec4 v_color;
  8.  
  9. uniform mat4 projection;
  10.  
  11. void main()
  12. {
  13.  
  14. vec2 norm = normalize(end - start);
  15. vec2 perp = vec2(-norm.x, norm.y);
  16.  
  17. float x0 = start.x;
  18. float x1 = end.x;
  19. float x2 = x1 + width / 2 * perp.y;
  20. float x3 = x0 + width / 2 * perp.y;
  21.  
  22. float y0 = start.y;
  23. float y1 = end.y;
  24. float y2 = y1 + width / 2 * perp.x;
  25. float y3 = y0 + width / 2 * perp.x;
  26.  
  27. vec3 pos_arr[6];
  28. pos_arr[0] = vec3(x0, y0, z);
  29. pos_arr[1] = vec3(x1, y1, z);
  30. pos_arr[2] = vec3(x2, y2, z);
  31. pos_arr[3] = vec3(x0, y0, z);
  32. pos_arr[4] = vec3(x2, y2, z);
  33. pos_arr[5] = vec3(x3, y3, z);
  34.  
  35. vec4 pos = vec4(pos_arr[gl_VertexID], 1);
  36. pos = projection * pos;
  37. gl_Position = pos;
  38.  
  39. v_color = color;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement