// c0 - view projection world matrix
// c4 - light color
// c5 - light direction
// c6 - ambient color
// c7 - texture scale
// c8 - layer position
// c9 - layer scale
// c15 - light view projection world matrix
// c19 - world matrix

vs_1_1
dcl_position v0
dcl_normal v1
dcl_texcoord0 v2

def c11, 0.5, 0.5, 0.5, 0.5
def c12, 1, 1, 1, 1
def c25, 1, 0, 0, 0

m4x4 r8, v0, c0		// transform vertices using view projection transform
mov oPos, r8

dp3 r0, v1, c5		// perform lighting N dot L calculation in world
mov r3, c12
add r2, r3, -c6
mul r0, r0, r2
add r0, r0, c6
mul oD0, r0.x, c4		// calculate final vertex color from light intensity and interpolated diffuse vertex color 
mov oD0.a, c12

mul r1, v2, c7
mov oT1.xy, r1
mov oT0.xy, v2		// copy texture coordinates to output

mad r1, v0.xyzx, c25.xxxy, c25.yyyx
dp4 r0.x, r1, c26
dp4 r0.y, r1, c27
dp4 r0.z, r1, c28
dp4 r0.w, r1, c29
dp4 oT2.x, r0, c30
dp4 oT2.y, r0, c31
dp4 oT2.z, r0, c32
dp4 oT2.w, r0, c33

mul r1, v2, c40
add r0, r1, c8
mov oT3.xy, r0