
instances( 15 )

lighting()

regc( 2, "FOG_PARAMS" )
regcn( 6, "CONST_PALETTE", 90 )


regi(0, "float4", "SS_POSITION")
regi(1, "float3", "SS_NORMAL")
regi(2, "float2", "SS_TEXCOORD0")
regi(3, "float2", "SS_TEXCOORD1")
regi(4, "float3", "SS_TANGENT")

vshader("

	vs.1.1

	def	c0, 1, 0, 0.5, 200.0

	mov	a0.x, v0.w

;uniformig (X,Y,Z,1) - removing index from W
	mad	r1, v0, c0.xxxy, c0.yyyx

;position
	dp4	oPos.x, r1, c[6 + a0.x]
	dp4	oPos.y, r1, c[7 + a0.x]
	dp4	oPos.z, r1, c[8 + a0.x]
	dp4	oPos.w, r1, c[9 + a0.x]

;fog
	dp4	r0.x, r1, c[8 + a0.x]
	mad	oFog.x, r0.x, c2.x, c2.y

;uv's
	mov	oT0.xy, v2
	mov	oT1.xy, v3

; calc tangent space basis, binormal = cross( normal, tangent )
	mov 	r2, v1
	mul 	r3, r2.zxyw, v4.yzxw;
	mad 	r3, r2.yzxw, v4.zxyw, -r3

; transform light dir into tanget space
	dp3 	r1.x, v4, c[11 + a0.x]
	dp3 	r1.y, r3, c[11 + a0.x]
	dp3 	r1.z, v1, c[11 + a0.x]

;dir 2 light in tangent space
	mad oD0, r1.xyz, c0.z, c0.z

")

