#version 330

precision highp float;

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

in VertexData
{
	vec3 worldPos;
	vec3 normal;
	vec2 texCoord;
} inData[];

out vec2 texCoord;

void main(void)
{
    float explode_factor = 5.0f;
    
    vec3 face_normal = normalize (
            cross (gl_in[2].gl_Position.xyz - gl_in[0].gl_Position.xyz,
                gl_in[1].gl_Position.xyz - gl_in[0].gl_Position.xyz));

    for (int i = 0; i < gl_in.length (); ++i)
    {
        texCoord = inData[i].texCoord;
        gl_Position = gl_in[i].gl_Position + vec4 (explode_factor * face_normal,
                0.f);
        EmitVertex ();
    }
    EndPrimitive ();
}