Vertex position calculation

The input to my vertex shader is a six-channel framebuffer object packed with the 3D coordinates of the endpoints of line segments(two RGB textures).
On the host, I’m generating a single quad per line segment using the conventional glBegin()/glEnd(). Each of the quad has the same position and orientation.
And I need a vertex program to position the vertices of the quads relative to those line segments, so that each quad has the same orientation as the corresponding line-segment.
The fragment program then textures the quads with a 2D pen texture to archieve the effect of NPR. So how to compute the vertex positions?

Your help is greatly appreciated

  1. get A, B
  2. pick an arbitrary vector for each line. cross this vector with the line AB to get a vector perpindicular to AB. (V1)
  3. normalize V1 and scale to rect width/2.
    Add V1 to A to get B(?), subtract it from A to get A(?). Add to B to get C(?), subtract to get D(?)

Thanks for your reply. Just forgot to mention that I need each quad be faced the camera, so I cannot pick an arbitrary vector. Will use the vector that points from A to the camera position then

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.