I’ve some problem about my fragment shader.
i have a function to calculate lighting define as
void diffuseHemiSphere(int i,vec3 normal,vec3 lightVec,float attenuation){
vec4 SkyColor = gl_LightSource[i].diffuse;
vec4 GroundColor = vec4(0.0,0.0,0.0,0.0);
float costheta = dot(normal, lightVec);
float a = 0.5 + 0.5 * costheta;
diffuseTerm += (a*SkyColor + (1.0-a)*GroundColor)*gl_FrontMaterial.diffuse*attenuation;
}
when i do something like this it work
for(int i=0;i<1;i++){
diffuseHemiSphere(i,normal,lightVec,0.15);
}
but when i use uniform variable as a loop count it does’nt work
for(int i=0;i<lightCount;i++){
diffuseHemiSphere(i,normal,lightVec,0.15);
}
“lightCount” is a uniform variable define in fragment shader,and I have successfully use it as
a if/else condition.
I have tried it on my both Geforce 7600gt/6100.
using the latest nvidia’s driver
Can someone explain it to me why it did’nt work.
Thank
Somboon