#version 450 core 
#extension GL_EXT_geometry_shader4 : enable

//Author: Chad Mourning
//Normal Geometry shader.
//Takes as input a triangle and outputs a line

layout(triangles) in;
layout(line_strip, max_vertices = 6) out;

layout ( binding = 0, std140 ) uniform CameraTransforms
{
   mat4 View;
   mat4 Projection;
   mat4 Shadow; //for shadow mapping
   // A Value of 0 = Render w/ No shadows
   // A Value of 1 = Generate depth map only
   // A Value of 2 = Render w/ Shadow mapping
   int ShadowMapShadingState;
} Cam;

uniform mat4 MVPMat;
uniform float length;

in vec3 vPos[];
in vec3 vNormal[];

void main(void)
{
    for (int i = 0; i < 3; ++i) {
        vec3 pos = vPos[i];
        vec3 normal = normalize(vNormal[i]);

        vec4 start = MVPMat * vec4(pos, 1.0);
        vec4 end   = MVPMat * vec4(pos - normal * 5, 1.0);

        gl_Position = start;
        EmitVertex();

        gl_Position = end;
        EmitVertex();

        EndPrimitive();
    }
}
