layout(triangles, invocations=2) in; layout(triangle_strip, max_vertices=3) out; out vec4 fcolor; in vec4 fca[]; in int gl_InvocationID; uniform mat4 mvp; void main(){ vec3 a = gl_in[2].gl_Position.xyz - gl_in[0].gl_Position.xyz; vec3 b = gl_in[1].gl_Position.xyz - gl_in[0].gl_Position.xyz; vec3 normal = normalize(cross(b,a)); for(int i = 0; i < 3; i++){ if(1 != gl_InvocationID) gl_Position = mvp * (gl_in[i].gl_Position + vec4(normal, 0) * 3); else gl_Position = mvp * gl_in[i].gl_Position; fcolor = fca[i]; EmitVertex(); } EndPrimitive(); }