I’ve been studying the Phong Shanding on GLSL these days, but the light coordinates doen’t work well.
I think it doesn’t be coincided between OpenGL and GLSL.
g_location_lightPos = glGetUniformLocationARB(g_porgObj, “lightPos”);
glUniform3fvARB(g_location_lightPos, 1, &g_lightPos);
How to coincide the light coordinates between OpenGL and GLSL?
You can access the lights coordinate using the gl_lightsource[i] uniform struct.
So you can use glLightfv(GL_LIGHTi, GL_POSITION, light_pos) and access that value in a vertex/fragment shader.
But beware of ATI’s GLslang implementation. At Catalyst 3.10 and Catalyst 4.1 the light position is NOT multiplyed by the current modelview matrix.
if you are passing the light-coordinate in as a uniform, you have to multiply it by the modelview-matrix in effect when you would call glLight(GL_POSITION, …) for fixed-function.
If you use the “normal” gl-state from the shader, it should be the right position already, but the current ATI driver has a bug in so far as that it doesn’t seem to be doing that transfrom.
Sorry, while writing, someone postet already
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.