!!ARBfp1.0 ATTRIB view = fragment.texcoord[1]; ATTRIB light = fragment.texcoord[2]; PARAM diffuse = program.local[0]; PARAM specular = program.local[1]; PARAM range = program.local[2]; TEMP colr, vdir, ldir, hdir, geom, txtr, temp; # Normalize V and L DP3 temp.x, view, view; DP3 temp.y, light, light; RSQ temp.x, temp.x; RSQ temp.y, temp.y; MUL vdir, view, temp.x; MUL ldir, light, temp.y; # Calculate H ADD hdir, vdir, ldir; DP3 temp, hdir, hdir; RSQ temp, temp.x; MUL hdir, hdir, temp; # Scale and bias N*H MAD txtr.x, hdir.z, range.x, range.y; # Calculate L*H DP3 txtr.y, ldir, hdir; # Look up product F(V,L)D(V,L)/pi TEX colr, txtr, texture[0], 2D; # Divide by N*V RCP temp, vdir.z; MUL colr, colr, temp; # Calculate geometrical attenuation # (May be omitted) RCP temp, txtr.y; MIN geom, vdir.z, ldir.z; ADD geom, geom, geom; MUL geom, geom, hdir.z; MUL_SAT geom, geom, temp; MUL colr, colr, geom; # Multiply specular by (1-k)C and add kCD(N*L) MUL temp, diffuse, ldir.z; MAD result.color, colr, specular, temp; END