uniform mat4 modelView;
uniform mat4 modelViewProj;
uniform vec4 fogColorAndDensity;
uniform vec4 lightingColor;

void main()
{
    vec3 eyePosition = (modelView * vec4(gl_Vertex.x , gl_Vertex.y, gl_Vertex.z, 1.0)).xyz;
    float fogDistance = length(eyePosition);
    float fogExponent = fogDistance * fogColorAndDensity.w;
    float fogFactor = clamp(exp(-abs(fogExponent)), 0.0, 1.0);

    gl_FrontColor.xyz = mix(fogColorAndDensity.xyz, lightingColor.xyz, fogFactor);
    gl_FrontColor.w = 1.0;

    gl_Position = (modelViewProj * vec4(gl_Vertex.x, gl_Vertex.y, gl_Vertex.z, 1.0));

    gl_TexCoord[0] = gl_MultiTexCoord0;
}
