varying vec2 TexCoord0;
varying vec3 LightDir, HalfVec;

uniform vec3 Eng_LocalLighting;
uniform vec3 Eng_LocalCameraPos;

attribute vec3 TSM0, TSM1, TSM2;

void main()
{
	TexCoord0 = gl_MultiTexCoord0.xy;
	mat3 TangentSpaceMatrix = mat3(TSM0, TSM1, TSM2);

	vec3 CamDir = TangentSpaceMatrix * normalize(Eng_LocalCameraPos - gl_Vertex.xyz);
	LightDir = TangentSpaceMatrix * Eng_LocalLighting;

	HalfVec = CamDir + LightDir;

	gl_Position = ftransform();
}
