uniform sampler2D spcTex1;
uniform sampler2D spcTex2;
uniform sampler2D spcTex3;
uniform sampler2D spcTex4;
varying vec3 eyeVec;

varying vec3 tangent;
varying vec3 biNormal;
varying vec3 normal;

varying vec3 lightVec;

varying float col;
void main(void)
{
	
	vec3 normalN = normalize(normal);
    vec3 viewVec = normalize(eyeVec);
	vec2 newTCoord=vec2(gl_TexCoord[0]);
	vec4 value = texture2D(spcTex1,vec2(newTCoord.x,newTCoord.y));
	vec4 nmap = texture2D(spcTex3,newTCoord.xy);
	
	
	vec3 lightVecz = normalize(vec3(0.0,-0.6,0.1));
	lightVecz=normalize(lightVec);
	
	vec3 nLight;
	//normalN.x = dot(tangent,nmap.xyz);
	//normalN.y = dot(biNormal,nmap.xyz);
	//normalN.z = dot(normal,nmap.xyz);
	float lightFactor = min(1.0,dot(nmap.xyz,lightVecz));
	vec4 value2= texture2D(spcTex2,gl_TexCoord[1].xy)*0.3;
	//lightFactor = min(0.1,dot(normalize(normal),lightVecz));
	lightFactor = clamp(lightFactor,0.0,1.0);
	//value.r=1.0;
	float spec = lightFactor;
	spec = pow(spec,12.0);
	spec=0.6;
	vec4 tangCol=vec4(tangent*0.5+vec3(0.5,0.5,0.5),1.0);//
	//value.xyz=vec3(1.0,1.0,1.0);
	//value2 = pow(value2,13.0);
	gl_FragColor =(value+value2)*gl_FrontMaterial.ambient*col;
}

