//cg program to do normal shading!!!!  how exciting!!!!
//input data
struct appdata 
{
	float4 position : POSITION;
	float4 normal : NORMAL;
	float2 texCoords : TEXCOORD0;
};


//output data
struct vertout
{
	float4 HPos	: POSITION;
	float4 color	: COLOR0;
	float3 vLightVector : TEXCOORD1;
	float2 texCoordsOUT : TEXCOORD0;
};

//the program to be run on every vertes
vertout main(appdata IN,uniform float4x4 ModelViewProj, uniform float4x4 ModelViewIT, uniform float3 LightVec)
{
	vertout OUT;			// Variable to handle our output from the vertex
					// shader (goes to a fragment shader if available).
	
	// Transform The Vertex Position Into Homogenous Clip-Space (Required)
	OUT.HPos = mul(ModelViewProj, IN.position);

    float3 lightVector = LightVec - IN.position;
     
	//xform normal from model-space to view-space
	float3 normalVec = normalize(mul(ModelViewIT, IN.normal).xyz);

	//store normalized light vector
	float3 lightVec = normalize(lightVector);
	OUT.vLightVector = lightVec;

    OUT.texCoordsOUT = IN.texCoords;
	//calculate the diffuse
	float diffuse = dot(lightVec, normalVec);

	//white diffuse material
	float3 diffuseMaterial = float3(0.0, 1.0, 0.0);

	//combine terms to make color
	OUT.color.rgb = diffuse * diffuseMaterial;
	OUT.color.a = 1.0;

	return OUT;
}