Register combiner normalization problem

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 :stuck_out_tongue: )

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);

Could you supply the config in nvparse form?

Did you forget combiner 0 ?

Cass, isn’t there an nvidia app that converts register combiner states into an nvparse script?

This is running on a geforce3 (or above), I assume?

And what are the default states of the final combiner?

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…

Originally posted by davepermen:
[b]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…[/b]

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

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