# note: lightFallTC = fragment.texcoord[2] # lightProjTC = fragment.texcoord[3] # calculate point light tc MOV R1, lightProjTC; MOV R1.z, lightFallTC.x; MAD R1.xyz, R1, 2.0, -1.0; # calculate projected light tc MOV R2, lightProjTC; MOV R2.z, -1.0; RCP R2.w, lightProjTC.w; MUL R2.xy, R2, R2.w; MAD R2.xy, R2, 2.0, -1.0; # sample projection cube map TEX lightCube, R1, texture[3], CUBE; TEX lightProj, R2, texture[3], CUBE; # calculate attenuation (x = point, y = projected) DP3 R1.x, R1, R1; POW R1.x, R1.x, 0.5.x; MOV R1.y, lightFallTC.x; ADD_SAT R1.xy, 1.0, -R1; MUL R1.xy, R1, R1; MUL lightCube, lightCube, R1.x; MUL lightProj, lightProj, R1.y; # if w > 1.0, light = projected, else light = point SLT R1.x, 1.0, lightProjTC.w; CMP atten, -R1.x, lightProj, lightCube;