PDA

View Full Version : Multitexturing with GL_ADD



kotrlar
01-16-2002, 12:10 AM
Hello,
could somebody help me, please, with multitexturing and GL_ADD setting in
glTexEnv? I use standard multitexturing with modulate and decal, but only
GL_ADD is not correct when I compare it to multipass rendering. I thing I
use right commands. We have blending ONE, ZERO in first pass (or ONE, ONE)
and ONE, ONE in second pass then I can use multitexturing with GL_ADD, but
multipass result (with blending) is different.
Please help.
Thank you!
Radovan Kotrla

Bob
01-16-2002, 12:26 AM
Is the result completely different, or just a little bit different? If it's just a little bit different, then I can say that the difference is due to roundoff errors (and similar stuff) in the different operations needed to produce the result.

kotrlar
01-16-2002, 01:06 AM
The result is completely different. When first pass is ONE, ONE and second ONE, ONE, then second texture is not visible and first is brighter.

Bob
01-16-2002, 01:22 AM
First pass doesn't need blending at all. Or do you require it for something else?

Anyways, post the code here so I can have a look at it.

kotrlar
01-16-2002, 01:37 AM
Yes, I sometimes use blending. Is the blending after multitexturing correct?
My code:
// First pass
pCurrPass = &pCurrShader->PassArray[i];
SetVertexColors();
BindTexture();
SetTextureCoords(0);
SetPassRenderState();
if (pCurrPass->Flags & PF_MULTITEX)
{
++i; // Next pass
pCurrPass = &pCurrShader->PassArray[i];
glActiveTextureARB(GL_TEXTURE1_ARB);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
if (pCurrPass->Flags & PF_MULTITEX_ADD)
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_ADD);
else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // Do not cache
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
BindTexture(1);
SetTextureCoords(1);
glDrawElements( GL_TRIANGLES, pVertexBuffer->NumIndices, GL_UNSIGNED_INT, pVertexBuffer->pIndices);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glClientActiveTextureARB(GL_TEXTURE0_ARB);

Bob
01-16-2002, 02:21 AM
You still haven't said if one of the techniques gives you correct result, only that there's a differencre between multitexturing and multipass rendering.

And that piece of code alone is not of much help. It says you call a few functions, and shows how you setup the second texture unit to add the two textures. Setting up the vertex array is not that relevant in this case.

Tell us, with more details, how you setup the two passes in multipass mode, and the two texture units in single pass mode. What states are enabled, disables, when they are disable/enabled, what values different function has, and so on.

j
01-16-2002, 11:20 AM
What video card are you using? Having multitexture does not guarantee that you have the GL_ADD blend mode - it's a separate extension.

j

Michalek366
01-18-2002, 01:43 AM
try Blend (ZERO, SRC_COLOR) or
Blend (SRC_COLOR, ZERO).

Hope this helps

kotrlar
01-18-2002, 03:32 AM
I found mistake. It's in second pass. Second pass can be used with multitexture only if color (for second pass) is white (identity). First pass can have color and blend mode must be One->Zero or One->One. Blend in second pass is One->One for GL_ADD.