#version 120

attribute vec4 vPosition;
attribute vec3 vNormal;

varying vec4 fColor;

uniform mat4 Projection;
uniform mat4 ModelView;
uniform mat4 CameraView;

uniform vec4 DiffuseProduct;
uniform vec4 SpecularProduct;
uniform vec4 LightPosition;

//uniform uint gDrawIndex; 
//uniform uint gObjectIndex; 

//uniform float Shininess;

//uniform int Shade;
//uniform int SpecToggle;

void
main()
{
	vec3 pos = (ModelView * vPosition).xyz;

	vec3 L = normalize( LightPosition.xyz - pos );
	vec3 E = normalize( -pos );
	vec3 H = normalize ( L + E );

	vec3 N = normalize ( ModelView * vec4(vNormal, 0.0) ).xyz;

	// Compute terms in the illumination equation
	vec4 ambient = vec4(0.2, 0.2, 0.2, 1.0);
    ambient = vec4(0.2, 0.2, 0.2, 1.0) * vec4(0.2, 0.2, 0.2, 1.0); // MatAmbient * LightAmbient

	float Kd = max( dot(L, N), 0.0 );
	vec4 diffuse = Kd*DiffuseProduct; // MatDiffuse * DiffuseColor
	
    gl_Position = Projection * CameraView * ModelView * vPosition;

	fColor = diffuse;
	fColor.a = DiffuseProduct.w;
}
