PDA

View Full Version : multitexturing -> multi pass



masterpoi
09-18-2002, 06:56 AM
i'm rendering a scene wich has a base texture/static lightmap/dynamic lightmap.
I'm using 3 texture units for this:


glActiveTextureUnit(GL_TEXTURE2_ARB); //Base map
if (m_LightmapsOnly) glDisable(GL_TEXTURE_2D);
else glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);

glActiveTextureUnit(GL_TEXTURE0_ARB); //Base lightmap
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
glEnable(GL_TEXTURE_2D);

glActiveTextureUnit(GL_TEXTURE1_ARB); //Dynamic 1
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
glBindTexture(GL_TEXTURE_2D, 1); //!!!!!!!!!!!!!!!!!!!!!!!

/* blah blah */

glMultiTexCoord2f(GL_TEXTURE2_ARB,iterator->Vertices[iterator->Indices[i]].tu,iterator->Vertices[iterator->Indices[i]].tv) ;
glMultiTexCoord2f(GL_TEXTURE0_ARB,iterator->Vertices[iterator->Indices[i]].lu,iterator->Vertices[iterator->Indices[i]].lv) ;
glMultiTexCoord2f(GL_TEXTURE1_ARB,iterator->Vertices[iterator->Indices[i]].d1u,iterator->Vertices[iterator->Indices[i]].d1v) ;

How can i achieve the same effect on a card that has only 2 tmus? I tried blending the dynamic lightmap over the modulated base texture and static lightmap, but that gives a lot of z-fighting. (and the wrong effect, i have to add static & dynamic map and then modulate it with the base texture)
Can i draw anything else between the different passes of a multi-pass algorithm. ?
I tried using polygonoffset, doesn't work. I'm probably using it in a wrong way.

MtPOI

MickeyMouse
09-18-2002, 07:34 AM
You shouldn't have z-fighting if you set depth function to GL_LEQUAL (and disable z-writing but that's only for optimization reasons).