



















































































































	
	
	



































































































;------------------------------------------------------------------------------
; Defines
;------------------------------------------------------------------------------












;------------------------------------------------------------------------------
; Diffuse color
;------------------------------------------------------------------------------

; Initialize diffuse color
mov		r9, c2

; Calculate the vertex-to-light vector, and project along the light's direction
add		r6, c10, -r11
dp3		r8.x, c11, r6

; Clip vertices behind the light to zero
sge		r4.x, r8.x, c10.w
mul		r9.w, r9.w, r4.x

; Apply N-dot-L shading to the diffuse alpha
dp3 r4.w, r6, r6 rsq r6.w, r4.w mul r6.xyz, r6, r6.w
dp3		r5.x, r1, c11					; Directional light shading
dp3		r5.y, r1, r6				; Point light shading
mov		r5.z, c0
dp3		r5, r5, c12			; Select type of shading to apply
max		r5.x, r5.x, c0.x
mul		r9.w, r9.w, r5.x

; Scale projected vertex-to-light vector and apply to the diffuse alpha
mad		r8.x, r8.x, c16.x, c16.y
max		r8.x, r8.x, c0
min		r8.x, r8.x, c1
mul		r9.w, r9.w, r8.x

; Copy the final color to output
mov		oD0, r9
