// Note: we not need v_clipVertex (CLIP version):
//	eyeSpaceVert == v_clipVertex

uniform	mat4	u_ModelViewMatrix;
uniform	mat4	u_ModelViewProjectionMatrix;
uniform mat4	u_transformMatrix;
out	vec2	texCoord;
out	vec3	Tangent;
out	vec3	Binormal;
out	vec3	Normal;
out	vec3	eyeSpaceNormal;
out	vec3	eyeSpaceVert;
#ifndef CSM
	uniform	vec3	u_CameraOrigin;
	out	vec3	eyeVec;
#else
	out	vec3	eyeSpaceTangent;
	out	vec3	eyeSpaceBinormal;
#endif
#if defined(FAKE_PPL)
	out	vec4	vertexColor;
#else
	out	float	vertexAlpha;
#endif
in	vec3	attr_Tangent;
in	vec3	attr_Binormal;
include		deforms.inc
include		colorGen_CSND.inc
include		tcGen_noFog.inc
void main(void)
{
	vec4 glVertex = DeformGeometry();
	tcGen(texCoord, glVertex.xyz);
	vec4 glTangent = vec4(attr_Tangent, 0.0);
	vec4 glBinormal = vec4(attr_Binormal, 0.0);
	vec4 glNormal = vec4(attr_Normal, 0.0);
	Tangent = (u_transformMatrix * glTangent).xyz;
	Binormal = (u_transformMatrix * glBinormal).xyz;
	Normal = (u_transformMatrix * glNormal).xyz;
	eyeSpaceNormal = (u_ModelViewMatrix * glNormal).xyz;
	eyeSpaceVert = (u_ModelViewMatrix * glVertex).xyz;
#ifndef CSM
	vec3 temp = u_CameraOrigin - glVertex.xyz;
	eyeVec.x = dot(temp, attr_Tangent);
	eyeVec.y = dot(temp, attr_Binormal);
	eyeVec.z = abs(dot(temp, attr_Normal));
#else
	eyeSpaceTangent = (u_ModelViewMatrix * glTangent).xyz;
	eyeSpaceBinormal = (u_ModelViewMatrix * glBinormal).xyz;
#endif
	gl_Position = u_ModelViewProjectionMatrix * glVertex;
#if defined(FAKE_PPL)
	vertexColor = colorGenLit(glVertex.xyz);
#else
	vertexAlpha = colorGenLit(glVertex.xyz).a;
#endif
}
