PDA

View Full Version : Light coordinates between OpenGL and GLSL.



360spider
02-09-2004, 05:15 AM
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...

Corrail
02-09-2004, 05:41 AM
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.

jeickmann
02-09-2004, 05:42 AM
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

jeickmann
02-09-2004, 05:43 AM
Sorry, while writing, someone postet already :-)