Multitexturing - Problem solveable?

There’s a little problem, I’ve got to solve, but I didn’t find the way to yet. Problem is the following:

I want to draw a polygon with two textures, each vertex of the polygon has it’s own color (using GL_Modulate). Light has to be disabled. The first texture shall be solid and the second shall be blended over the first, with an own intensity for every vertex. In immediate-mode it would about like this:

glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);

glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);
glColor3f(0.5f,0.5f,0.5f);
glVertex3fv(&V1);
glTexCoord2f(0.0f,1.0f);
glColor3f(0.4f,0.4f,0.4f);
glVertex3fv(&V2);
glTexCoord2f(1.0f,1.0f);
glColor3f(0.3f,0.3f,0.3f);
glVertex3fv(&V3);
glTexCoord2f(1.0f,0.0f);
glColor3f(0.2f,0.2f,0.2f);
glVertex3fv(&V3);
glEnd();

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);
glColor4f(0.5f,0.5f,0.5f,0.7f);
glVertex3fv(&V1);
glTexCoord2f(0.0f,1.0f);
glColor4f(0.4f,0.4f,0.4f,0.6f);
glVertex3fv(&V2);
glTexCoord2f(1.0f,1.0f);
glColor4f(0.3f,0.3f,0.3f,0.5f);
glVertex3fv(&V3);
glTexCoord2f(1.0f,0.0f);
glColor4f(0.2f,0.2f,0.2f,0.4f);
glVertex3fv(&V3);
glEnd();

How to do the same using multitexturing?

Thanks,

  Michael Ikemann / Virtual XCitement Gmbh.

MrCalab,

On GeForce with register combiners, this is easy:

nvparse(
"!!RC1.0                                 "
"{                                       "
"  rgb {                                 "
"    spare0 = tex0 * col0;               "
"    spare1 = tex1 * col1;               "
"  }                                     "
"}                                       "
"{                                       "
"  rgb {                                 "
"    discard = unsigned_invert(col0.a)   "
"            * spare0;                   "
"    discard = col0.a * spare1;          "
"    spare0 = sum();                     "
"  }                                     "
"}                                       "
"out.rgb = spare0;                       ");

glEnable(GL_REGISTER_COMBINERS_NV);

// first pass color -> primary color
// first pass texture -> tex0
// second pass color -> secondary color
// second pass texture -> tex1
// second pass alpha -> primary alpha

glBegin(GL_QUADS);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,0);
glColor3f(.5,.5,.5,.7);
glSecondaryColor3fEXT(.5,.5,.5);
glVertex3fv(&V1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0,1);
glColor3f(.4,.4,.4,.6);
glSecondaryColor3fEXT(.4,.4,.4);
glVertex3fv(&V2);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,1);
glColor3f(.3,.3,.3,.5);
glSecondaryColor3fEXT(.3,.3,.3);
glVertex3fv(&V3);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1,0);
glColor3f(.2,.2,.2,.4);
glSecondaryColor3fEXT(.2,.2,.2);
glVertex3fv(&V4);

glEnd();

Hope this helps…
Cass

Thanks for the listening, but I in any case need it working for all cards, supporting multitexturing in any way, not just Geforce+, after all we’ve to sell a game and the most of the people who’ll buy our game will surely not have a Geforce but more TNT or TNT2, so…is there also a possibility without using registercombiners? By the way this command is not at least working on my Geforce 2 MX. Ah yes, before I forget it, is there any SDK especially for the Geforce 1 and 2? I downloaded the actual SDK and there was written : “May be that some of the demos will just run on the Geforce 3.” Yeah, may be that SOME of the demos won’t work, hehe, yeeeha, ONE WHOLE DEMO worked, vertexarrayrange…although…ah yes, one simple bumpmap-demo as well, but…great, first of all I don’t have a Geforce 3, because not at least in my worst neightmares I would pay such an amount of money for a graphiccard, second the people out there not too, at least 99.9% not. So…I just want to use the standard-arb commands for doing this, is it possible with them as well?

Thanks,

     Michael / VX

Michael,

Without using register combiners, you can still achieve most of the effect you describe.

  1. Enable texture0
  2. Bind texture
  3. GL_DECAL
  4. Enable texture1
  5. Bind texture
  6. GL_MODULATE
  7. Draw

Cass, can you speak to what is lost using this method vs. multipass vs. reg combiners?

Regards,

Glossifah

For TNT you can use NV_texture_env_combine4 to implement this equation. There may be a way to do this in a cross-platform way with some of the new ARB texture blending extensions.

Glossifah,

The equation you want is:

C = (1-A0)(C0T0) + A0(C1T1)

I don’t think this is what you get at all with the texture blending setup you suggest.

Thanks -
Cass

So is there a possibility to reach the same with multitexturing as with a two-pass rendering or is it impossible? I’ve one time tried to use combiners4, but I also didn’t reach it with the use of this. But to talk about register-combiners again…is it correct that it’s not available for a Geforce 2 MX or is my driver already too old? And how would the soltuions look like? One time using regcombiners and the version without, if it’s possible without as well?

Thanks,

  Michael / VX

the geforce2mx (as well as all geforces) supports register combiners.
cass has written the necessary code above.

Hi all,
first of all, where is the function “nvparse” declared and is it available in Delphi as in C++, which library do I need to link for this?
Is there any tool with which I can “debug” my combiner-scripts?

Thanks,

   Michael

You can find the nvparse library in the OpenGL SDK @ nVidia

Hm…is there also a Delphi-version available or just C++?
Cuz of the sad matter that the project is written in Delphi, it will be unuseable for me, if it’s not in any way linkable by the Delphi-compiler. Cass? :wink:

     Michael