<cgvp>
<variablemap variable="light 0 position" destination="LightPos" />
<variablemap variable="light 0 diffuse" destination="LightColor" />
<program>
<![CDATA[

struct app2vertex {
	float4 Position : POSITION;
	float3 Normal : NORMAL;
	float2 TexCoord : TEXCOORD0;
	float3 Tangent : TEXCOORD1;
	float3 BiNormal : TEXCOORD2;
};

struct vertex2fragment { 
	float4 Position : POSITION;
	float2 TexCoord : TEXCOORD0;
	float3 oLightDir : TEXCOORD1;
	float3 oEyeVec : TEXCOORD2;
};

vertex2fragment main (app2vertex IN,
	uniform float4x4 ModelViewI : state.matrix.modelview.inverse,
	  /* The matrices are bound with the state.matrix.... semantics.
	     For more info see the Cg and ARB_vertex_program docs.
	     */
	uniform float4x4 ModelViewIT : state.matrix.modelview.invtrans,
	uniform float4x4 ModelViewProj : state.matrix.mvp,
	uniform float4 LightPos,
	uniform float3 LightColor)
{
	vertex2fragment OUT;
	
	float3 objLight = mul(ModelViewI, LightPos).xyz;
	objLight -= IN.Position;
	
	float3x3 obj2tang;
	obj2tang[0] = IN.Tangent;
	obj2tang[1] = IN.BiNormal;
	obj2tang[2] = IN.Normal;
	
	float3 tangLight = mul (obj2tang, objLight);
	
	
	float3 eyeVec = ModelViewIT[3] - IN.Position;
	float3 tangEyeVec = mul (obj2tang, eyeVec);
	
	
	OUT.Position = mul (ModelViewProj, IN.Position);
	OUT.TexCoord = IN.TexCoord;
	OUT.oLightDir = normalize(tangLight.xyz);
	OUT.oEyeVec = normalize(tangEyeVec.xyz);
	
	return OUT;
}

]]>
</program>
</cgvp>
