Bug 17266 - gl_NormalMatrix definition is wrong
Summary: gl_NormalMatrix definition is wrong
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-22 14:39 UTC by Jiri Svoboda
Modified: 2011-02-09 06:27 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Jiri Svoboda 2008-08-22 14:39:59 UTC
gl_NormalMatrix, defined at line 84 of slang_builtin.c, in lookup_statevar() is not defined correctly. The definition:

{ "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE },

is same as for gl_ModelViewMatrix. However, the normal matrix is equal to the 3x3 top-left submatrix of the modelview matrix only if the modelview matrix is orthogonal (i.e. its columns have length equal to 1.0). If the modelviewmatrix is not orthogonal (i.e. scaling is applied), this does not hold.

The normal matrix should be computed as the inverse transpose of the top-left 3x3 submatrix of the modelview matrix, as described in section 2.11.3 of the OpenGL 2.1 specification.
Comment 1 Adam Jackson 2009-08-24 12:30:49 UTC
Mass version move, cvs -> git
Comment 2 Marek Olšák 2011-02-09 06:27:59 UTC
From the looks of the code, this appears to be fixed (uniform.c):

static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = {
   { NULL, { STATE_MODELVIEW_MATRIX, 0, 0, 0, STATE_MATRIX_INVERSE},
     SWIZZLE_XYZW },
   { NULL, { STATE_MODELVIEW_MATRIX, 0, 1, 1, STATE_MATRIX_INVERSE},
     SWIZZLE_XYZW },
   { NULL, { STATE_MODELVIEW_MATRIX, 0, 2, 2, STATE_MATRIX_INVERSE},
     SWIZZLE_XYZW },
};

Closing. Feel free to reopen if you still have issues.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.