gl_NormalMatrix

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
l99057j
Gnoblar
Posts: 14
Joined: Wed Aug 28, 2013 1:19 pm

gl_NormalMatrix

Post by l99057j »

I am writing a shader that needs the normal matrix. Reading online, it looks like the following is the definition of a normal matrix...
the transposed inverse of the upper 3x3 of the product of the Model and View matrices
So my first inclination is to use a named_parameter_auto with inverse_transpose_worldview_matrix. But the documentation doesn't make it clear whether this takes only the upper 3x3 or is using the whole matrix. Can anyone elaborate on this and tell me if I'm using the right thing or there is a better alternative?
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: gl_NormalMatrix

Post by bstone »

You should use only the top 3x3 block from that matrix to transform normals.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: gl_NormalMatrix

Post by scrawl »

I think if you set the w component (of the vector you are multiplying with the matrix) to 0, you could also use the 4x4 matrix with the same result.
Post Reply