VERTEX
varying vec4 fres;
uniform mat4 SkinMatrices[100];
void main()
{
	vec3 lightDir;
	vec4 fLightDir;
	vec3 normal;
	vec4 diffuse;
	float NdotL;


	vec4 p  = gl_Vertex;

	vec2 weights1 = gl_MultiTexCoord1.xyz ;
	vec2 weights2 = gl_MultiTexCoord2.xyz ;
	vec2 weights3 = gl_MultiTexCoord3.xyz ;

	p = p *SkinMatrices[int(weights1.r )] * weights1.g + 
	 p *SkinMatrices[int(weights2.r )] * weights2.g +
	 p *SkinMatrices[int(weights3.r )] * weights3.g;


	normal = normalize(gl_NormalMatrix * gl_Normal);

	lightDir = normalize(vec3(gl_LightSource[0].position));
	NdotL = max(dot(normal, lightDir), 0.0);
	diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;

	gl_FrontColor =  NdotL * diffuse + gl_FrontMaterial.ambient;

	fLightDir = gl_ModelViewMatrix * gl_Vertex ;
	fLightDir.z-=10.0;
	fLightDir = -normalize(fLightDir);
	NdotL = max(dot(normal, vec3(fLightDir.x,fLightDir.y,fLightDir.z)), 0.0);
	float f = max(gl_FrontMaterial.specular.b - (NdotL * gl_FrontMaterial.specular.g +  gl_FrontMaterial.specular.r),0.0);
	fres= vec4(f,f,f,0);
	gl_Position =  ftransform();

	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_TexCoord[1].s = 1.0-normal.x *0.5+ 0.5;
	gl_TexCoord[1].t = 1.0-normal.t *0.5+ 0.5;

}
PIXEL
uniform sampler2D tex,tex1;
varying vec4 fres;
uniform float lerp_value;
uniform vec4 lerp_color;
void main()
{
	gl_FragColor =  gl_Color * texture2D(tex,gl_TexCoord[0].st) + texture2D(tex,gl_TexCoord[0].st).a * texture2D(tex1,gl_TexCoord[1].st);
	gl_FragColor += fres;
	gl_FragColor = gl_FragColor * (1.0-lerp_value) + lerp_value * lerp_color;
}
