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: What parts of the 4x4 Modelview transformation get applied to normals?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2006
    Posts
    2

    What parts of the 4x4 Modelview transformation get applied to normals?

    I am capturing data from my OpenGL applications by listening to function calls on the other side of the OpenGL library. The goal is to generate 3D model files (ie. .obj) that represent the rendered geometry in eye/view coordinates. that is, after the Modelview transformation, but before projection or perspective.

    By applying the current 4x4 ModelView matrix to all vertices, I am able to reconstitute my geometries no problem. But now I am trying to add in the vertex normals to my output, and have a question:

    does the entire 4x4 ModelView matrix get applied to the initial [u,v,w] values for normals to produce the final [u,v,w] values? it would seem that since normals are only directional, you might only want to apply the Rotation (and possibly Scale) components of the ModelView matrix to the normals.

    Any thoughts?

    thanks,
    mike

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: What parts of the 4x4 Modelview transformation get applied to normals?

    Normals aren't transformed by the modelview matrix, but by the transpose of the inverse of the modelview matrix. For rotations only, they are the same, but not when translation, shearing and scaling and so are introduced.

    Anyway, normals are transformed by the entire 4x4 matrix, just like any other vertex. Normals have the fourth coordinate set to zero, so any translation in the matrix will in practice not affect the normal. Also be aware that any non-zero component in the fourth row in the matrix (typically present in a projection matrix) will also affect the normal, so using the top left submatrix is not enough if you want the general case.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2006
    Posts
    2

    Re: What parts of the 4x4 Modelview transformation get applied to normals?

    so, in short, i should get the correctly transformed normal values in eye/view coordinate space if I:

    1) make sure the 4th value of the normal vector is zero

    2) multiply it by the transpose of the inverse of the modelview matrix

    jah?

    thanks,
    mike

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: What parts of the 4x4 Modelview transformation get applied to normals?

    Exactly

    It may be neccesary to re-normalize the normal afterwards to make sure it is unit-length.

Posting Permissions

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