Hi,
I'm working on a set of material shaders using multiple lights. For
each shader, I'm hardcoding the for loop max that calculates the
per-light shading with the expectation that the compiler will unroll
it. In benchmarking the compiler optimizations, I'm actually unable
to index into the gl_LightSource array with the for loop parameter.
For example:
vec4 color = vec4(0., 0., 0., 0.);
for(int i=0; i < 1; i++) {
vec3 Ldir = normalize(gl_LightSource[i].position.xyz - P);
vec4 ambient = La*Ka;
vec4 diffuse = Kd*Ld*max(dot(Nn, Ldir), 0.);
vec3 Hn = normalize(Ldir + Vn);
vec4 specular = Ks*Ls * pow(max( dot(Nn, Hn) , 0.), shininess);
color += ambient + diffuse + specular;
}
and
vec3 Ldir = normalize(gl_LightSource[0].position.xyz - P);
vec4 ambient = La*Ka;
vec4 diffuse = Kd*Ld*max(dot(Nn, Ldir), 0.);
vec3 Hn = normalize(Ldir + Vn);
vec4 specular = Ks*Ls * pow(max( dot(Nn, Hn) , 0.), shininess);
vec4 color = ambient + diffuse + specular;
do not produce identical results as I expected. In the latter case, I
can move the light around and the shader adapts. In the former case,
the light position of GL_LIGHT0 is decoupled from the shader
calculations somehow. Anone else experience this?
I'm on an nvidia 8600M with the latest osx 10.4 updates.
thanks,
wes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden