PDA

View Full Version : Register combiner normalization problem



razor
04-14-2002, 01:51 PM
I'm trying to normalize the vector that is in the primary color register. The program works fine if i just use the vector without trying to normalize it (but of course it's not normalized when the normals at the vertices are varying a lot). When i use the following code however, it's not correct (the normal that is produced seems to be shifted, so all the lights are semi directional :p )

Can anyone see whats wrong with the code?

glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER1_NV, GL_RGB,
GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV,
GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);


glCombinerInputNV(GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_C_NV, GL_PRIMARY_COLOR_NV, GL_HALF_BIAS_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_D_NV, GL_SPARE1_NV, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER2_NV, GL_RGB,
GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE1_NV,
GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);


// calculate the dot product between light vector and normal vector
glCombinerInputNV(GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE0_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER3_NV, GL_RGB,
GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV,
GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE);

cass
04-14-2002, 06:01 PM
Could you supply the config in nvparse form?

PH
04-14-2002, 07:07 PM
Did you forget combiner 0 ?

kieranatwork
04-14-2002, 10:51 PM
Cass, isn't there an nvidia app that converts register combiner states into an nvparse script? http://www.opengl.org/discussion_boards/ubb/smile.gif

knackered
04-14-2002, 11:27 PM
This is running on a geforce3 (or above), I assume?

knackered
04-14-2002, 11:39 PM
And what are the default states of the final combiner?

davepermen
04-15-2002, 12:29 AM
glCombinerInputNV(GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

use SIGNED_IDENTITY.. your vector can have negative components..

razor
04-15-2002, 07:52 AM
Originally posted by davepermen:
glCombinerInputNV(GL_COMBINER3_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

use SIGNED_IDENTITY.. your vector can have negative components..

Thanks a lot dave, that was the problem (it's hard as all heck to debug those register combiners, kind of a pain).. someone should make a software simulator where values can be looked at.

Thanks again

davepermen
04-15-2002, 09:22 AM
why? took me some seconds to find the solution.. whyle everyone cried for nvparse-code i am trained with the rc's like this.. and its quite easy if you write down what you see..

for checking code, i'm always there http://www.opengl.org/discussion_boards/ubb/wink.gif