ps_2_0
// calculates sphere normals using sphere positions and spheres desctexld r0,t0,s0
//   tex0 is render result
//   tex1 is spheres desc texture (32F)
//   {tex2 is spheres colors texture (argb)}
//   tex3 is sphere_pos
dcl t0
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
def c8,100,0.9,0,0
def c9,256,-128,0,0
texld r0,t0,s0
mul r0.g,r0.g,c8.x
mov r2.y,c8.z
mov r2.x,r0.b      // sphere index from blue component
sub r3,c8.y,r0.b
texkill r3
rcp r3.x,c1.x
mul r2.x,r2.x,c9.x
frc r2.z,r2.x
sub r2.x,r2.x,r2.z
mul r2.x,r2.x,r3.x
texld r3,r2,s1     // get indexed sphere desc
mad r3,r3,c9.x,c9.y
texld r2,t0,s3
sub r2,r2,r3
nrm r3,r2
mov oC0,r3
