Transforming normals propertly
#1
Posted 23 September 2005 - 08:56 PM
I'm doing lighting in world space so I need the world transformation matrix of an object do transform the normals. I also know that I have to take the transpose of the inverse world matrix and multiply the normals by it. After that i have to renormalize them. But the question is: is there anything i'm forgetting?
Thank you!
#2
Posted 23 September 2005 - 10:44 PM
#3
Posted 24 September 2005 - 07:53 AM
#4
Posted 24 September 2005 - 09:40 PM
#5
Posted 25 September 2005 - 08:18 PM
And you can supply the transformation matrix per-object anyway, so I had no need to transform my normals at all.
#6
Posted 26 September 2005 - 01:36 AM
OpenGL transforms normals by the inverse transpose automatically, so it's true that when you specify a modelview matrix, you don't need to worry about any of this yourself. However, I think Mihail's article is intended to explain what is going on "under the hood" with regard to transformations. Correct?
#7
Posted 26 September 2005 - 07:03 AM
#8
Posted 26 September 2005 - 08:04 AM
why don't you light in model space? Do you use more lights per object than your object has normals? Also keeping an unscaled version of the modelview matrix along with a possibly scaled one would save you inverting and renormalization completely.
Alex
#9
Posted 26 September 2005 - 09:15 AM
No, it isn't equal. However, you shouldn't translate your normals so in practice there is no difference.
-Also keeping an unscaled version of the modelview matrix along with a possibly scaled one would save you inverting and renormalization completely.
This would break if the scale was non-uniform...
#10
Posted 26 September 2005 - 10:39 AM
#11
Posted 26 September 2005 - 04:17 PM
SigKILL said:
No, it isn't equal. However, you shouldn't translate your normals so in practice there is no difference.
I should have made it clear that the inverse transpose part applies only to the upper-left 3x3 submatrix, in the case that we are using 4x4 matrices on real projective space for our transformations. In this case, the upper 3x3 submatrix contains only rotations, so it is orthogonal and its inverse equals its transpose; hence the inverse transpose equals the original matrix.
#12
Posted 27 September 2005 - 12:14 AM
#13
Posted 27 September 2005 - 08:28 AM
A Unified Lighting Technique for a New Generation of Games
URL: http://www.gamasutra...acroix_01.shtml
#14
Posted 17 March 2008 - 07:01 AM
would I just multiply them by the modelview matrix like I would for an ordinary vertex? or are there other opperations?
This is for plane-plane intersections
#15
Posted 17 March 2008 - 07:38 AM
#16
Posted 17 March 2008 - 09:45 AM
XORcist said:
A Unified Lighting Technique for a New Generation of Games
URL: http://www.gamasutra...acroix_01.shtml
Errr ... ok ... sounds like the way everyone i've ever come across handles per-pixel lighting ...
#17
Posted 17 March 2008 - 09:48 AM
#18
Posted 17 March 2008 - 03:51 PM
#19
Posted 19 March 2008 - 10:38 AM
JarkkoL said:
So to keep my modelview matrix orthonormal I must only apply scaling and rotations to it and no translations?
#20
Posted 19 March 2008 - 11:16 AM
Quote
Nope.
You must not apply any scaling (except for 1 and -1, that is).
This is best proven by an example:
Consider an unit matrix with ones as diagonal elements, and zeroes everywhere else. This matrix obviously is orthonormal (each row or column vector has a magnitude of one, and each two different row or column vectors are orthogonal to each other).
Now, scaling involves multiplying this matrix with a scaling matrix, with scale factors s_1 to s_n on the diagonal and zeroes everywhere else. The new matrix U * S is the scale matrix itself. Since you at least assume some kind of scaling, one of the s_i is not 1 or -1, thus there now is a row vector that is not normalized anymore (i.e. has a length of s_i), thus the result is not orthonormal.
Translations may be applied to your orthonormal matrix without affecting normal transformations.
Be a little bit careful here: Generally, a 3x3 matrix fully specifies a coordinate frame (aka rotation) in 3D. However, we use 4x4 matrices so that we can handle transformations in a uniform way (i.e. with the same multiplication also used for rotations). For this to work out correctly, we need to augment each 3D vector with a fourth coordinate ( we can't multiply a 4x4 matrix with a 3-element vector). The way we choose the fourth coordinate influences how the vector is transformed by the matrix.
A fourth coordinate of 0 essentially (work this out on paper) removes the influence of the added line and row in our 4x4 transformation matrix, the result is the same as if we multiplied a 3-element vector with the 3x3 rotational part only. As a consequence, we use a fourth coordinate of 0 when we wish to transform directional vectors (i.e. normals, for example-> these represent a direction, rather than a point in space)
A fourth component of 1 includes all translations, and is used for actual points within space (i.e. vertices of a model).
Hope this lights things up a bit,
Cheers,
- Wernaeh
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












