View Full Version : Vertex Programs
09-04-2001, 12:53 AM
I've got a problem with TrackMatrixNV(enum target, uint address, enum matrix, enum transform);
Thr last parameter - transform - could be one of the following values:IDENTITY_NV,INVERSE_NV,TRANSPOSE_NV and INVERSE_TRANSPOSE_NV.
So, what I understood:
IDENTITY_NV: Tracks the Matrix as it is e.g. (vector)a' = (matrix)M*(vector)a
INVERSE_NV: Tracks the inverse of the matrix. e.g. (vector)a = (inverse matrix)M^-1*(vector)a. If you have eyespace coordinates you can transform them back in world-space one's.
BUT: What does TRANSPOSE_NV and INVERSE_TRANSPOSE_NV mean (my poor english...)? And what does it? Why do you track normals with INVERSE_TRANSPOSE_NV and not with IDENTITY_NV?
09-04-2001, 02:23 AM
Transpose of a matrix is like this:
If M1 =
[a b c d]
[e f g h]
[i j k l]
[m n o p]
then M1' =
[a e i m]
[b f j n]
[c g k o]
[d h l p]
Hope that helps.
09-04-2001, 02:39 AM
Thanks, that helps. http://www.opengl.org/discussion_boards/ubb/smile.gif
I try to understand Nutty's spec_nvp on www.nutty.org (http://www.nutty.org) . There he made the following transformations (all with the ModelView-Matrix): he transforms the vertex-position with GL_IDENTITY_NV. The normal is transformed with GL_INVERSE_TRANSPOSE_NV and the light with GL_INVERSE_NV.
Why this? why can't I(he) transform everything with the GL_IDENTITY_NV?
09-04-2001, 03:19 AM
Because normals don't have to be translated such as vertex position, only the rotation part of the matrix is useful (the scaling part can be too easily "annuled" by normals renormalisation or rescaling).
09-04-2001, 03:41 AM
Ok. And if I use GL_INVERSE_TRANSPOSE_NV only the Rotation-part of the matrix will by applied? I can't imagine that. The inverse of a Matrix A transforme a already transformed (with Matrix A) point back.
Is there a rule, that vertex are transformed with the identity, the normals with the inverse_tranpose, and the light by transpose?
I don't get it.
09-04-2001, 04:08 AM
That's the point. You won't transform points with the inverse transpose, you will tranform the normals with this. It takes into account, that movement doesn't affect normals, as uniform scaling does not too.
09-04-2001, 04:47 AM
Ok. I think I got it now. Thank you all
09-04-2001, 11:23 PM
But what is with the Light-Poition? With the Normals it's clear. They stand for a direction, so translation would be fatal. The Light-Position should be translated an rotated like a usual Vertex, shouldn't it?
09-05-2001, 02:00 AM
c[0-4] ModelView Matrix
"DP3 R0.x ,v[NRML] ,c;"
"DP3 R0.y ,v[NRML] ,c;"
"DP3 R0.z ,v[NRML] ,c;"
Wouldn´t this transform the normal only with
the 3x3 rotation part of the modelview matrix
or am i totally wrong?
so if this is correct why the transpose matrix?
09-05-2001, 03:03 AM
Dont look at me, I just wrote the things! http://www.opengl.org/discussion_boards/ubb/smile.gif
If any of it is wrong, someone tell me, and I'll sort them out.
Seems to work thoug...
09-05-2001, 03:18 AM
I think this should be right,too...
Same question here...
For the Light-Pos, the transformation with identity should be right, not? (No inversed Matrix)
09-05-2001, 03:36 AM
It depends on what nutty has done in his program. If he uses the vertices ,transformed in eye-space (with the identity) ,I think you have to put the light also in eye-space ,but if he uses the vertices of the object in object-space I think you have to use the inverse?!?!
if I´m wrong please help me!
09-05-2001, 04:11 AM
The light's position is affected by the normal modelview matrix.
09-05-2001, 04:13 AM
Let's presume the following szenario:
First I set the viewers position with some rotation an translation: Matrix A
I draw an Object: I "push" the current matrix,do some other roatations and translations and draw (Matrix B), and "pop".
So which Matrix will the VP receive by the drawing? A or B? if only Matrix B, how can I transforme the vertices in eye-space? How can I distinguish in the VP between object-space(Matrix B) and eyepspace (Matrix A)?
09-05-2001, 04:15 AM
I'm tired... of course by the projection matrix...
09-05-2001, 11:56 AM
The lighting is done in object space.
The modelview matrix takes object space into world space. Thus to convert the world space light into object space we use the inverse modelview matrix.
I think that explains it nicely.
09-05-2001, 12:59 PM
Huh? Are you talking about per-pixel lighting using the vertice's space?
09-05-2001, 09:38 PM
Ok, Nutty, that makes sense. So, for the normals we consider only the rotation, for the lighting we transform with the inverse the world-space coordinates of the light. So you got everything in object-space and may calculate lighting...
09-05-2001, 11:34 PM
Michael, No. Not per pixel, just vertex lighting, done in object space. Prevents redunatant transforms of vertices to world space, doing lighting in object space, thats why I did it like that.
09-06-2001, 03:25 AM
Why do you do pervertex lighting by hand, when OpenGL and HW TnL provide it much faster I guess? Are you targetting for below GeForce? Just curious.
09-06-2001, 04:10 AM
I think his demo on www.nutty.org (http://www.nutty.org) shows how a basic Vertex Program should be writen. e.g. vertex transformation etc.
For my part, I understand now, how it works and written my own VP for the setup of dot3-bumpmapping.
09-06-2001, 12:50 PM
It is using hardware on GF3. Coding custom lighting algo's by hand, can even be faster, as you're making the lighting equations specific to your needs.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.