Multitexturing woes, and the common man. AKA me.

I am attempting to create a multitexture environment similar to the infamous quake 3. Using the equation brought to us the the gaming GODS “ID”. P=(L+B)*T+S, or pixel color= (Light map + Bump Map) * Texture + Specular map

Would this do that? Concidering I am writing the function for cards that only support 2 textures per Pass?

//Bump Map
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, BumpMap);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);

//Inverted Bump Map
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, InvertedBump);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);

// General Switches
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);

//Setup Vertex info
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &VertPT);

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, &NormalPT);

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glTexCoordPointer(2, GL_FLOAT, 0, &TextureVerts);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB(GL_TEXTURE1_ARB); glTexCoordPointer(2, GL_FLOAT, 0, &BumpVerts);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

//Draw first pass (using updated Tex coords using the tangent space funcion)
glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, &VertIndexPT);

//Reset texture information
//Light Map
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, LightMap);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);

//Base texture
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, BaseTexture);
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);

//Turn stuff back on
glEnable(GL_BLEND);
glEnable(GL_LIGHTING);

//Resetup Vertex info
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &VertPT);

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, &NormalPT);

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glTexCoordPointer(2, GL_FLOAT, 0, TextureVerts);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

//Redraw
glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_INT, &VertIndexPT);

This is as far as i have gone so far… Would this work so far? I use a function to find the tangent space for the bump maps. Then using the combined Bump and inverted bump, I create the bump maping, then i draw the scene. Then I redraw the scene adding the light map to the bump map, then multiplying the texture the the combined light/bump map. Does this look right so far? And is there any way, short of using another texture unit i can now add the Specular map with out doing another pass on the geometry??? thanks in advance.

What’s the point of posting the same code to the list again?

People read the threads. You’re also asking if a block of code will work at a high level when you have already claimed you wrote the code, and it has been discussed in detail in another thread.

Surely you know what you implemented. Compile it to see if it works as you intended. It also clearly doesn’t do some of the things you are asking about which you should know.

There is nothing in this code which will do +S for specular. That “+S” is also a bump mapped (V.L ^ exponent) so it’s a good deal more complex than just +S, Carmack uses DOT3 texturing for diffuse on most cards. He might have a very basic path for diffuse which is as you describe.

There have been loads of threads discussing bumpmappiong and the internet is awash with examples.

There’s no bumpmapping in quake3 - specular or otherwise.

:slight_smile: I assume he meant Doom 3.