GL_NV_register_combiners -> GL_ARB_texture_env_*

Is it possible to convert this example ( Advanced Per-Pixel Lighting ) which uses NV_reg_combiners to use the ARB_texture_env_(combine|crossbar|dot3) extensions?

If someone has already done this and has the code, it would be even better.

Also, can you point me to a few tutorials on the ARB_texture_env_* extensions (already had a look at the exts registry - didnt help too much as there wasnt a concrete example on how to set this stuff up). The NV_reg_comb ext has very good docs on the nVidia site so this was a little easier to understand (except the finer details on the Final Combiner, which mostly went over my head :slight_smile: ).

Extensions are a deadly nightmare especially for noobs like me. I think it would help a lot of beginners to easily move on to them if opengl.org had a registry listing along with links to sites or their own examples that explain how to use them (atleast the ARB ones if nothing else).

TIA for all the help.

There are loads of demos at nVidia that use texture combiners.

Sites like nehe.gamedev.net are a good resource. There are many out there.

No I haven’t converted that one, but there was one called Per Pixel Lighting from the same person and I had converted it to use ARB_tex_env.

It’s was really easy. It’s pretty much mathematics on how you want to calculate a color.

Example from Per Pixel Lighting

//WITH REGISTER COMBINERS
//We need 2 texture units
//active texture 1 (the 1D radial ramp texture)
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, ZtextureID);

//active texture 0 (the 2D radial map texture)
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, XYtextureID);

//setup and enable the register combiners
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, (float*)&color);

glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);

glEnable(GL_REGISTER_COMBINERS_NV);

===================================
//WITH TEXTURE COMBINER
//We need 2 texture units
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, XYtextureID);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
//RGB : 1 - texture0
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
//ALPHA : replace
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);

glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, ZtextureID);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
//RGB : previous_stage - texture1
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_SUBTRACT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
//ALPHA : previous_stage
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);

a bit along these lines

is there an ARB or general workaround for nv_combine4 ?
one that uses 1.3 ogl stuff

None that I am aware of.
NV_combine_4 was introduced to expose the capabilities of the RIVA TNT, NV_register_combiners exposes the capabilities of GeForce1-4.