My relatively simple geometry shader
#version 330 core
layout (lines) in;
layout (triangle_strip, max_vertices = 3) out;
void main() {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gl_Position = 3 * (vec4 (0, 1, 0, 1) + vec4 (0, 0, 0, 1) + vec4 (1, 1, 0, 1));
EmitVertex();
EndPrimitive();
}
for some reason, computes the third vertex by vector interpolation instead of vector addition, multiplication by scalar does not work either.
Not sure what you're asking, but your maths seems off. Note that
3 * (vec4(0, 1, 0, 1) + vec4(0, 0, 0, 1) + vec4(1, 1, 0, 1))
== 3 * (vec4(1, 2, 0, 3))
== vec4(3, 6, 0, 9)
== vec4(1/3, 2/3, 0, 1)
You probably want this:
vec4(3 * (vec3(0, 1, 0) + vec3(0, 0, 0) + vec3 (1, 1, 0)), 1)
== vec4(3 * vec3(1, 2, 0), 1)
== vec4(3, 6, 0, 1)