











































































































































































































;------------------------------------------------------------------------------
; Defines
;------------------------------------------------------------------------------







;------------------------------------------------------------------------------
; Diffuse color
;------------------------------------------------------------------------------

; Calculate normalized light vector
add		r6, c11, -r11
dp3 r4.w, r6, r6 rsq r6.w, r4.w mul r6.xyz, r6, r6.w

; Calculate attenuation factor
dst		r4, r4.wwww, r6.wwww
dp3		r4.w, r4, c12
rcp		r8.w, r4.w

; Calculate normalized eye vector
add		r7, c10, -r11
dp3 r4.w, r7, r7 rsq r7.w, r4.w mul r7.xyz, r7, r7.w

; Calculate normalized half vector
add		r10, r7, r6
dp3 r4.w, r10, r10 rsq r10.w, r4.w mul r10.xyz, r10, r10.w

; Calculate self-shadowing term
dp3		r4, r1, r10
sge		r4, r4, c0

; Store attenuated material color in diffuse channel
mov		oD0.xyz, c2
mul		oD0.w, r8.w, r4.w

; Transform H vector into texture space and store in the specular channel
dp3		r4.x, r10, r2
dp3		r4.y, r10, r3
dp3		r4.z, r10, r1
mad		oD1.xyz, r4, c13, c13
