Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Light coordinates between OpenGL and GLSL.

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Posts
    3

    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...

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: 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.
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Cologne, Germany
    Posts
    27

    Re: Light coordinates between OpenGL and GLSL.

    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

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Cologne, Germany
    Posts
    27

    Re: Light coordinates between OpenGL and GLSL.

    Sorry, while writing, someone postet already :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •