Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: gl_LightSource[0].position

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

    gl_LightSource[0].position

    Hi,

    I'm trying to implement some kind of simple lighting in a GLSL vertex shader.
    Currently I'm using a directional light and I'm trying to get the L-Vector for the diffuse calculation like this:

    vec3 lightDir = normalize(gl_LightSource[0].position.xyz)

    The only problem is, this position doesn't change if I rotate the scene, etc.
    (I tried this by simple setting the vertex-color to that value)
    The GL-Spec says, that the position gets stored after having been transformed by the modelview-matrix, so it should change when I rotate the view.
    If I use fixed-function lighting, it works.
    Has anybody else experienced this issue or can tell me what I'm doing wrong?
    I'm using an ATI Radeon 9800 with Catalyst 4.1

    Thanks,

    Jan Eickmann

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

    Re: gl_LightSource[0].position

    I had a similar problem. Seems like the ATI driver doesn't multiply the light position with the modelview matrix if you are using GLslang.

    [This message has been edited by Corrail (edited 02-08-2004).]
    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: gl_LightSource[0].position

    Thanks for the info. At least I'm happy that I didn't do something stupid in my shader. Well for now, I'll just have to pass it in as a uniform.

    Jan

    Btw: is there any list for the current limitations in the ATI driver concerning GLSL?

    [This message has been edited by jeickmann (edited 02-09-2004).]

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Waltham, MA
    Posts
    24

    Re: gl_LightSource[0].position

    Hi there,

    I believe the issue with gl_LightSource[n].position has been resolved and will be fixed in a future release. I will double check to make sure.

    There is a list of known GLSL caveats that ATI maintains. Please contact 'devrel@ati.com' to receive it.

    Thanks.

    -- Dan (ATI)

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

    Re: gl_LightSource[0].position

    > There is a list of known GLSL caveats that ATI maintains. Please contact 'devrel@ati.com' to receive it.

    Already did that last thursday, thank you. No answer yet, though. Thats why I was asking here.

    Thanks for clearing it up though.

    Jan

    P.S: please don't misunderstand this as being unpatient.

    [This message has been edited by jeickmann (edited 02-09-2004).]

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Waltham, MA
    Posts
    24

    Re: gl_LightSource[0].position

    Hi Jan,

    Thanks for your patience, I spoke with devrel and you should hear back today.

    Also, I was incorrect, this issue has not been fixed. We will try to reproduce it. If you have a reproducer app, please send it to 'devrel@ati.com' as this will expediate the issue being fixed.

    Thanks.

    -- Dan (ATI)

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Oegstgeest, The Netherlands
    Posts
    11

    Re: gl_LightSource[0].position

    Hi all. I'm totally new to shading languages and i'd like to learn. I've seen some examples and this thread seemed to explain my problem. It doesn't, but here it is anyways:

    vec3 LightDir = normalize(gl_LightSource[0].position.xyz);
    LightDir -= v;

    I get the error :
    gl_LightSource left of '[' is not of type array, matrix or vector. Did i forget something? Please help...

    Thanx,
    Marty

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

    Re: gl_LightSource[0].position

    what graphics card are you using? In 3dlabs drivers, gl-state based on arrays or structs is not yet supported. So you have to supply this info as a uniform.

    If it's an ATI, it "should" work. At least you shouldn't get a compile error. As stated above, the implementation is buggy insofar, as that you have to manually multiply the light-pos with the modelviewmatrix.
    I mailed a test-shader to ATI devrel, so hopefully, it will be fixed in the next driver release.

    Regards,
    Jan

  9. #9
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Oegstgeest, The Netherlands
    Posts
    11

    Re: gl_LightSource[0].position

    Ok, thanx... Suddenly it works I downloaded the new ATI drivers (for my radeon 9600 xt, 256MB) and it works fine now. I get a link error when I use noise functions though. This is what i did:

    vec4 SomeRandSeed = vec4(1,1,1,1);
    vec4 MyNoise = noise4(SomeRandSeed);

    Ow. I read some 'tutorials' but I still can't find out how to use the uniforms. I can declare them in the shader, but how to I communicate from my application (in cpp)?

    Thanx,
    Marty

  10. #10
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Oegstgeest, The Netherlands
    Posts
    11

    Re: gl_LightSource[0].position

    Ok, I got it now... Thanx anyways for the help. My first shader works, per fragment lighting and my own dot3 bumpmapping

Posting Permissions

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