PDA

View Full Version : Two bump-mapping questions



yoale
05-05-2003, 03:19 PM
Alright, I think I've got it!!! http://www.opengl.org/discussion_boards/ubb/biggrin.gif
I have a light vector that is from a light source to a vertex that has been tranformed to eye space. Now, if I multiply this vector by the inverse modelview matrix, I get the vector in object space right?

Now here's what I'm thinking...The inverse of a matrix that has only been rigidly transformed (ie no scales or skews), is just the transpose of itself (I read it in a math book at least http://www.opengl.org/discussion_boards/ubb/smile.gif.) Now, is it the same if the matrix has been translated? Or does the translation somehow throw off the inverse calcs? http://www.opengl.org/discussion_boards/ubb/confused.gif

The thing is, I have a bump-mapping algorithm that works well if a light position and three vertices are passed in. The trouble comes when I try to bump map only knowing a vertex, its normal, and a light position. I'd love to use the alg I already have (which requires three vertices), but my boss wants the alg to work if only one vertex can be known at any given time http://www.opengl.org/discussion_boards/ubb/mad.gif http://www.opengl.org/discussion_boards/ubb/mad.gif. I'd appreciate any help. http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif


[This message has been edited by yoale (edited 05-05-2003).]

jwatte
05-05-2003, 03:26 PM
Yes, the translation throws it off. That's because the 4x4 is no longer orthonormal.

yoale
05-05-2003, 03:34 PM
Aha!!!! I thought so. Now, I'm curious if there is a way to compute the inverse without resorting to Gausian Elimination (did I spell that right? http://www.opengl.org/discussion_boards/ubb/tongue.gif)

yoale
05-05-2003, 03:50 PM
Well, thanx jwatte! I think I have the necessay calcs!

According to something I found in an ATI demo...
inv[13] = matrix[12,13,14] dotprod matrix[0,1,2]
inv[14] = matrix[12,13,14] dotprod matrix[4,5,6]
inv[15] = matrix[12,13,14] dotprod matrix[8,9,10]

That's it then, right? If so, this was by far the quickest I've ever resolved a programming problem, in less than an hour! Thanks again! Keep up the good work. http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif http://www.opengl.org/discussion_boards/ubb/biggrin.gif

[This message has been edited by yoale (edited 05-05-2003).]

jwatte
05-06-2003, 10:46 AM
Congratulations! You solved the problem by using available information on the web. This is one of the best skills to have. (That, and debugging).

Basically, what happens in that code is that you invert the rotation, and then back-rotate the offset part. This works as long as there is no skew or stretch.