Converting from nvparse RC1.0

Hello,

I’m trying to convert the combiner state from the “Vertex program for register combiner bump mapping setup” (what a name) effect in NVidia’s CG Effects Browser to a sequence of OpenGL state calls.

Here’s the RC1.0 string:

!!RC1.0
{
rgb {
spare0 = expand(col0) . expand(tex0);
spare1 = expand(col1) . expand(tex0);
}
}
{
rgb {
spare1 = spare1 * spare1;
}
}
final_product = spare1 * spare1;
out.rgb = spare0 + final_product;
out.a = unsigned_invert(zero);

And here’s my (failed) attempt at converting it to opengl state calls:

glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);

glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_CONSTANT_COLOR0_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE0_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_CONSTANT_COLOR1_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_TEXTURE0_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);

glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_SPARE1_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_TRUE, GL_FALSE);

glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE1_NV, GL_SIGNED_IDENTITY_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);

glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

Can anyone spot the mistakes?

col0 maps to GL_PRIMARY_COLOR_NV not GL_CONSTANT_COLOR0_NV and col1 maps to GL_SECONDARY_COLOR_NV.

The second CombinerOutput call should not have GL_TRUE in the abDotProduct parameter since you want to multiply ab.

Other than that it looks correct.

Wonderful that was it!

So the combiner will by default do A * B and C * D if the dot product values are not set to true (and muxsum is post those operations anyway).

Thanks for the color catch too!