PDA

View Full Version : Register Combiner weirdness



Zeno
11-17-2000, 09:14 AM
I'm working on learning to use register combiners, but there is something weird going on and I don't understand it.

Here's the setup:

// Enable 1 combiner
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV , 1);

// Put texture 0 in register A glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

// Set register B to one
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV,GL_ONE, GL_UNSIGNED_IDENTITY_NV,GL_RGB);

// Put A*B in spare 0
glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

// A = 0
glFinalCombinerInputNV(GL_VARIABLE_A_NV,
GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

// B = 0
glFinalCombinerInputNV(GL_VARIABLE_B_NV,
GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

// C = 0
glFinalCombinerInputNV(GL_VARIABLE_C_NV,
GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

// D = Spare0
glFinalCombinerInputNV(GL_VARIABLE_D_NV,
GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);

// E = 0
glFinalCombinerInputNV(GL_VARIABLE_E_NV,
GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

// F = 0
glFinalCombinerInputNV(GL_VARIABLE_F_NV,
GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);

// G = 1
glFinalCombinerInputNV(GL_VARIABLE_G_NV,
GL_ONE, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);


Now, since the output RGB = AB + (1-A)C + D, whatever I give as input to register A should be all that I see, since everything but D is set to zero at the end. This works fine for GL_PRIMARY_COLOR_NV, GL_SECONDARY_COLOR_NV, GL_FOG, GL_TEXTURE1_ARB, but NOT GL_TEXTURE0_ARB!!!

Instead, it comes out black (i.e. Nothing). I am certain that I enable texture0, because if I just comment out the glEnable for the combiners, it works fine, and I see both textures on my geometry.

If anyone has an idea why I can't see texture0, please let me know.

Thanks,
Zeno

mcraighead
11-17-2000, 10:15 AM
It sounds strange that most of them would work and one would fail, but I do have a suggestion.

There is no GL_ONE register. Instead, you should be using GL_ZERO with GL_UNSIGNED_INVERT_NV.

If that doesn't fix it, you might try accessing the texture directly in the final combiner rather than using the value in Spare0.

- Matt

Zeno
11-17-2000, 12:40 PM
Well, I found the problem. Unfortunately it wasn't anything you guys could have known about.

The texturemap that was appearing black is created on startup from a rendering to the back buffer. This rendering has no texture maps on it. What happened was I enabled the above register combiner stuff, did this rendering (which was black because only texture 0 color could get through my filter, and there was no texture 0) and pulled the (black) data into a texturemap. Commenting out the glEnable() for the register combiners fixed this of course, so that's why I was confused.

Thanks for telling me about the enumerant problem, Matt http://www.opengl.org/discussion_boards/ubb/smile.gif

Zeno