Archived

This topic is now archived and is closed to further replies.

Gammastrahler

How to draw three texures using mutlitexturing??

Recommended Posts

Hi, i have trouble blending three textures using mutlitexturing. My 3D card has only 2 texture units, and for two textures, it works (texture and lightmap). but i have trouble getting a third texture, i use a second rendering pass and change to the desired texture, but i still only get two textures! here´s my source for rendering:
  
glActiveTextureARB(GL_TEXTURE0_ARB); 
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, GetTextureID()); 
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, GetLightmapID()); 
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glBegin(GL_TRIANGLES);

   glMultiTexCoord2fARB(...);
   glMultiTexCoord2fARB(...);
   glVertex3f(...);

   2. vertex and 3. vertex

glEnd();
// second pass with third texture


glActiveTextureARB(GL_TEXTURE1_ARB); 
glBindTexture(GL_TEXTURE_2D, GetDetailMapID()); 		
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glBegin(GL_TRIANGLES);

   glMultiTexCoord2fARB(...);
   glMultiTexCoord2fARB(...);
   glVertex3f(...);

   2. vertex and 3. vertex

glEnd();

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
  
can anyonle heelp me on this? thanks Gammastrahler

Share this post


Link to post
Share on other sites
If you're drawing the exact same triangle, use GL_LEQUAL (or GL_GEQUAL) as depth comparison function. And you also need that glBlendFunc.

And, hmm, you know that your code actually blends 4 textures ? I don't know if that is intended, you are doing: (pass1) tex0 * tex1, (pass2) tex0 * tex2. If you want tex0 * tex1 * tex2, then you need to disable the second texture unit before drawing the second pass, and load your third texture into unit 0. What blending equation are you after ?

[edited by - Yann L on June 9, 2002 7:15:40 PM]

Share this post


Link to post
Share on other sites