
void main_fp(	  float3 objectPos : TEXCOORD1,
		  float3 oNormal   : TEXCOORD2,
		  out float4 color     : COLOR,
		  uniform float4 lightDiffuse,
		  uniform float4 lightSpecular,
		  uniform float3 ambientcolor,
		  uniform float4 lightPos,
		  uniform float3 eyeposition,
		  uniform float4 lightAtt,
		  uniform float shininess,
		  uniform float kd,
		  uniform float ka,
		  uniform float ks)
{
	
	  float d = distance(objectPos, lightPos.xyz);
	  d=1.0 / ( lightAtt.y+ lightAtt.z * d + lightAtt.w * d * d);
	  float3 L =lightPos.xyz-objectPos.xyz;
	  L = normalize(L);
	  float diffuseLight = max(dot(L, oNormal), 0);
	  float3 diffuseResult = d * 
			  lightDiffuse.xyz * diffuseLight;
	  float3 V=eyeposition - objectPos;
	  V = normalize(V);
	  float3 H = normalize(L + V);
	  float specularLight = pow(max(dot(H, oNormal), 0), 
				    shininess);
	  
	  if (diffuseLight <= 0) specularLight = 0;
	  float3 specularResult = d * 
			   lightSpecular.xyz * specularLight;
	 color.xyz=ka*ambientcolor+kd*diffuseResult+ks*specularResult;
	 
	 color.w=1.0;
}
