#version 330 core

out vec4 fColor;
in vec4 vColor;
in vec3 vScalar;
in vec4 fPos;
in vec4 fnormal;

uniform float blend;
uniform bool lighting;

vec4 lightPos = vec4(0,10,100,1);

void main()
{
    if(lighting)
    {
        vec4 lightDir = normalize(lightPos - fPos);
        vec3 color = vScalar*blend+vColor.rgb*(1-blend);
        vec3 ambient = 0.1*vec3(1,1,1);
        vec3 difuse = abs(dot(normalize(fnormal),normalize(lightDir)))*0.9*vec3(1,1,1);
        fColor = vec4(abs(ambient+difuse)*color,vColor.a);
    }
    else
    {
        fColor = vec4(vScalar*blend+vColor.rgb*(1-blend),vColor.a);
    }
}
