layout (location = 0) in vec2 start; layout (location = 1) in vec2 end; layout (location = 2) in float z; layout (location = 3) in vec4 color; layout (location = 4) in float width; out vec4 v_color; uniform mat4 projection; void main() { vec2 norm = normalize(end - start); vec2 perp = vec2(-norm.x, norm.y); float x0 = start.x; float x1 = end.x; float x2 = x1 + width / 2 * perp.y; float x3 = x0 + width / 2 * perp.y; float y0 = start.y; float y1 = end.y; float y2 = y1 + width / 2 * perp.x; float y3 = y0 + width / 2 * perp.x; vec3 pos_arr[6]; pos_arr[0] = vec3(x0, y0, z); pos_arr[1] = vec3(x1, y1, z); pos_arr[2] = vec3(x2, y2, z); pos_arr[3] = vec3(x0, y0, z); pos_arr[4] = vec3(x2, y2, z); pos_arr[5] = vec3(x3, y3, z); vec4 pos = vec4(pos_arr[gl_VertexID], 1); pos = projection * pos; gl_Position = pos; v_color = color; }