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 3 of 3

Thread: Transforming normals

  1. #1
    Intern Contributor
    Join Date
    Aug 2003
    Location
    Urbana, IL
    Posts
    57

    Transforming normals

    Not sure if this is the right place for this. It seemed about halfway between beginner and advanced to me.

    I am running into a problem using OpenGL lights. I have a number of triangle lists being driven off of vertex arrays. One of the vertex arrays is a normal list. Each triangle list has a transformation matrix associated it which gets loaded with a glLoadMatrixd right before the list gets drawn with a glDrawElements.

    Before the loop that draws the triangle stip, I setup the light (a single infinite distance light).

    What is going wrong is that either the normals are not transforming, or the sun direction is transforming with the normals effectively cancelling it out, making the lighting look like it was simply painted on the object with a static lightmap.

    Can someone give a clearer picture of what should be happening when. I checked the red book and it wasn't as clear as I would have liked on the subkect/
    Geoffrey DeWan

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962

    Re: Transforming normals

    Lights are transformed to eye space through the modelview.

    You should not position the lights after the model matrix has been multiplied on the modelview unless the lights are positioned in the object space of that model matrix.

    If the lights are in eye space position them when identity is on the modelview.

    If the lights are in world space, position them after the viewing matrix transformation is on the modelview.

    If the lights are in object space or have their own matrix position them after that matrix has been multiplied on the modelview.

  3. #3
    Intern Contributor
    Join Date
    Aug 2003
    Location
    Urbana, IL
    Posts
    57

    Re: Transforming normals

    Thanks. I got it sorted out.
    Geoffrey DeWan

Posting Permissions

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