ps_2_0
// input: render result, shadow test origin, arctangents, texture map, shadowcast res, shadow test dir
//   c0 - light origin
//   c1 - ambient light
//   c2.y - object id
dcl t0
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
dcl_2d s4
dcl_2d s5
def c8,256,-128,100,128
def c9,0,0,0,0.1
def c10,0.999,0,0,0
texld r2,t0,s0
sub r2.b,r2.b,c2.y
abs r2.b,r2.b
mul r3,r2.b,c8.y
texkill r3                    // handle only the specified object
texld r3,t0,s1
sub r4,c0,r3
mov r6,r3
mov r3.z,c9.x
nrm r5,r4
nrm r4,r3
dp3 r3.x,r4,r5
mov r0,r3.x
abs r0,r0
texld r2,t0,s4
texld r3,t0,s5
sub r2.x,r3.w,r2.g
cmp r0,r2.x,c10.y,r0             // shadow cast
add r0,r0,c1
texld r1,t0,s2
mov r1.y,r6.z
mul r1.y,r1.y,c9.w
texld r1,r1,s3
mul r0,r0,r1
mov oC0,r0
