#version 150

in  vec4 vPosition;
in  vec4 vColor;
in  vec2 vTexCoord;
in  vec4 vTexCoord3D;

out vec3 fV;
out vec3 fL;
out vec4 ambient2;


struct llum
{
    vec4 pos;
    vec3 dir;
    vec4 int_ambient;
    vec4 int_difusa;
    vec4 int_especular;
    float ang;
};

struct material
{

    vec4 comp_ambient;
    vec4 comp_difusa;
    vec4 comp_especular;
    float coef;
};

uniform llum l;
uniform material matPrimari;
uniform material matSecundari;
uniform vec4 obs;
uniform vec4 ambient;

// Define the interface between the vertex- and the fragment programs

struct vertex_fragment
 {
   vec4 Position; // For the rasterizer
   vec4 TexCoord;
   vec4 Pos;
   vec4 Color;
};

uniform mat4 model_view;
uniform mat4 projection;

out vertex_fragment IN;

void main(void)
{

    fV = vPosition.xyz;
    fL = l.pos.xyz;

    ambient2 = ambient;

    if( l.pos.w != 0.0 ) fL = l.pos.xyz - vPosition.xyz;

    gl_Position = projection*model_view*vPosition;
    gl_Position = gl_Position/vPosition.w;


    IN.Position = projection*model_view*vPosition;
    IN.Pos = projection*model_view*vPosition;
    IN.TexCoord = vTexCoord3D;
    IN.Color = vColor;

}
