I draw a line consisting of triangles in OpenGL.
Now I work where:
Vertex buffer: {v0, v1, v2, v3}
Index buffer (triangle strip): {0, 1, 2, 3}

The top image is the raw data transferred to the vertex shader, and the bottom is the vertex shader output after applying the offset to v1 and v3 (using the vertex attribute).
My goal is to use one vertex at a point on the line and generate the offset in another way. I was looking at gl_VertexID, but I need something more like an item id. Here is my desired setup:
Vertex buffer: {v0, v2}
Index buffer (triangle strip): {0, 0, 1, 1}
and use the imaginary gl_ElementID % 2 to offset each other vertex.
I am trying to avoid using geometric shaders or additional vertex attributes. Is there any way to do this? I am open to completely different ideas.
source share