layout(triangles, invocations=3) in; layout(line_strip, max_vertices=8) out; out vec4 fcolor; in vec4 fca[]; 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(a,b)); vec4 avg = vec4(0, 0, 0, 0); for(int i = 0; i < 3; i++){ gl_Position = gl_in[i].gl_Position; fcolor = fca[i]; EmitVertex(); gl_Position = gl_in[i].gl_Position + vec4(normal, 0); fcolor = fca[i]; EmitVertex(); EndPrimitive(); avg += gl_in[i].gl_Position; } gl_Position = avg; fcolor = vec4(0, 0, 0, 1); EmitVertex(); gl_Position = avg + vec4(normal, 0) * 3; fcolor = vec4(0, 0, 0, 1); EmitVertex(); EndPrimitive(); }