#version 150
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

in vec4 position[];

out vec3 color;

uniform mat4 modelviewproj;

void main(void)
{
	vec3 n = normalize(cross(position[1].xyz - position[0].xyz, position[2].xyz - position[0].xyz));
	float c = 0.7 * abs(dot(n, normalize(vec3(1,1,1)))) + 0.15;
	color = vec3(c, c, c);

	gl_Position = modelviewproj * position[0];
	EmitVertex();

	gl_Position = modelviewproj * position[1];
	EmitVertex();

	gl_Position = modelviewproj * position[2];
	EmitVertex();

	EndPrimitive();
}