Light coordinates between OpenGL and GLSL

Hi.

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[0]);

How to coincide the light coordinates between OpenGL and GLSL?
Please help…

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.

Jan Eickmann

Sorry, while writing, someone postet already :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.