Jump to content
• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# transforming vertex normals

This topic is 5664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

"A normal is a vector representing a plane." <-- we'll use this.

So I take "0.85355, -0.14645, 0.50000", a normal, which is a vector representing a plane. I plug those vector values in to the corresponding x, y, and z spots in an identity matrix (along the right hand side, as above), viola, I have a 4x4 matrix representation of that normal/vector.

Then I can rotate the normal through regular matrix transformation, resulting in a transformed normal. As long as I don't get it confused with regular 'worldspace' vectors, and handle it properly, it should be fine, afaik.

Basically, my thinking is, if it is a vector in any sense, I can transform it like a vector.

As I said, I know there is a better way to do this, but that's for somebody else to tell me.

All tolled, it looks like the method that chipmunk is using is correct.

[edited by - wudan on August 19, 2003 9:43:57 AM]

#### Share this post

##### Share on other sites
Advertisement
I kinda see how you got there, but I'm not sure why.

Transformation of a point P by a 4X4 matrix M:

 P' = M * P [x']       [x] [y'] = M * [y] [z']       [z] [1]        [1]

Transformation of a normal N by (e.g. the same) 4X4 matrix M:

 N' = (MT)-1 * N [x']        [x] [y'] = (MT)-1 * [y] [z']        [z] [0]         [0]

(I might have the T,-1 inside out)

However, if M is orthogonal then MT = M-1
so (MT)-1 = M and you can do

 N' = M * N

Which is what the OP was trying to do.

[edited by - JuNC on August 19, 2003 11:28:36 AM]

#### Share this post

##### Share on other sites
I haven''t read the whole thing but i guess what you might be doing wrong is transforming the normals using the same MV matrix that you are using for vertex transformationg. That''s wrong... i am sure someone have already mentioned it above... you should not TRANSLATE the normals. Only the rotational components of the MV matrix should be used.. ie. ONLY the top-left 3x3 part of the 4x4 matrix. Just leave out the last column and last row of the 4x4 matrix and use the remaining 3x3 matrix.

in OGL vertex shader this is achieved by

DP3 NormalVector.x NormalVector ModelViewMat[0]
DP3 NormalVector.y NormalVector ModelViewMat[1]
DP3 NormalVector.z NormalVector ModelViewMat[2]

Notice.. we r doing a DP3 (3 component dot product).

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 13
• 16
• 13
• 13
• 9
• Advertisement
• ### Forum Statistics

• Total Topics
634453
• Total Posts
3017546
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!