How can I access the positions of pairs of vertices?
You cannot do this simply if you just use the vertex and fragment shader. A simple way is to use geometric shaders . Inside this shader stage, you can access the pair of vertices that make up your line segment. Then just determine the line orientation and pass it to the fragment shader.
If the geometric shader is not an option (because of your target audience), you can duplicate the geometry (keeping at each vertex the actual vertex plus the next vertex), and then perform the calculations in the vertex shader.
source
share