Hi all,
This is my first time posting here so i hope i ask this in the right section of the forum.
I use a geometry shader to create a line between to points like so:
vec4 p1 = gl_in[0].gl_Position;
vec4 p2 = gl_in[1].gl_Position;
vec2 dir = normalize((p2.xy - p1.xy) * viewport);
vec2 offset = vec2(-dir.y,dir.x) * line_width / viewport;
texcoord = vec2(0.,0.);
gl_Position = p1 + vec4(offset.xy * p1.w, 0.0, 0.0);
EmitVertex();
texcoord = vec2(1.,0.);
gl_Position = p1 - vec4(offset.xy * p1.w, 0.0, 0.0);
EmitVertex();
texcoord = vec2(0., 1.);
gl_Position = p2 + vec4(offset.xy * p2.w, 0.0, 0.0);
EmitVertex();
texcoord = vec2(1., 1.);
gl_Position = p2 - vec4(offset.xy * p2.w, 0.0, 0.0);
EmitVertex();
I now want to create texture coordinates for my created line.
You can see my attempt in the code above. This works a bit but when i rotate the camera the coordinates don’t always work.
Does anyone know a solution to my problem? Thanks!y