// c0 - view projection world matrix
// c4 - light color
// c5 - light direction
// c6 - ambient color
// c7 - material diffuse color
// c8 - material emmisive color
// c9 - world matrix

vs_2_0
dcl_position v0
dcl_normal v1
dcl_texcoord0 v2

def c12, 1, 1, 1, 1

m4x4 oPos, v0, c0

// calculate lighting
mov r0, c5
m3x3 r2.xyz, r0, c9
nrm r1, r2

dp3 r0, v1, r1

mov r3, c12
sub r2, r3, c6
mul r0, r0, r2
add r0, r0, c6

mul r0, r0.x, c4
mul r0, r0, c7
add r0, r0, c8
min r0, r0, c12
mov r0.a, c7.a
mov oD0, r0

// copy texture coordinates to output
mov oT0.xy, v2