Strange, both are compiled successfully - but both versions show a grey gradient only. Seems like this the following line 155 is never true:
if (t < THRES)
Hmm ... did not understand this function anyway:
// find the nearest intersection point of the ray with the scene
float intersectScene(vec3 p, vec3 d)
{
float t= THRES;
for (int i=0;i< BALLS; i++) {
t= intersectSphere(p, d, sphere[i], colors[i], t);
}
return t;
}
Seems like you return the intersectSphere value of the last ball anyway ... yawn... or maybe it is just too early for me ;-)