ps_2_0
// pixel shader to prepare spheres intersection results to receive shadows
// inputs:
// tex0 - spheres_desc (x,y,z,r, 32F)
// tex1 - render result buffer (distances, indices, 32F)
// tex2 - intersecting ray origins
// tex3 - intersecting ray directions
// c1.x - number of spheres = width of spheres desc texture
// outputs shadow test ray position
def c7,-128,-128,-128,0
def c6,100,99.9,256,0
def c8,128,256,0,0
def c9,-1,-1,0,0
def c10,0,0,0,0
dcl t0
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
texld r0,t0,s1
//mad r1,r0.g,c9.x,c9.y
//texkill r1
mul r0.g,r0.g,c6.x
mov r1.y,c6.w
mov r7,c7
texld r3,t0,s2
mad r3,r3,c6.z,r7    // ray orig
texld r4,t0,s3
mad r4,r4,c6.z,r7    // ray dir
mad r4,r4,r0.g,r3    // dir * dist + orig = pos
sub r0.g,r0.g,c6.y
cmp r4,r0.g,c10,r4
add r4,r4,c8.x
rcp r5.x,c8.y
mul r4,r4,r5.x       // encode it
mov oC0,r4
