How to set the alpha of multitexture?

I’m using ARB_multitexture extension for lightmapping, but the lightmap shadows are just too dark. How could I change the alpha value of specific multitexture.
I tried GL_TEXTURE_ENV_COLOR, but I couldn’t get it work.

Lightmapping has nothing to do with alpha blending. If you have a texture T and a lightmap L, what you’re calculating is simply L*T. Alpha is never considered.

I don’t think you can make it look brighter on-the-fly without using an extra texture unit or resorting to pixel shaders. The easiest solution is to do it off-line: just add an ambient lighting term to your lightmaps.

– Tom

Ok. I made some pretty good invention .
I put one “brightmap” for each level, which is blitted on every lightmap durring their loading progress. This makes possible things like lighting the whole level and setting a cool color (at nigh blue color looks awsome).

>>I’m using ARB_multitexture extension for lightmapping, but the lightmap shadows are just too dark<<

youre using modulate i take it?
try add_signed_arb or modulate+scale*2

add_signed_arb definition is not included in gl.h, where can I get that?
For the second question I would ask:
How to do overbrighting with lightmaps?

Originally posted by blender:
add_signed_arb definition is not included in gl.h, where can I get that?

Get glext.h here and also read the rest of that page.

For the second question I would ask:
How to do overbrighting with lightmaps?

Not sure what you mean. In ARB_texture_env_combine and basic ARB_multitexture modes, you can’t get any brighter than 1.0 because results are clamped to the range [0…1] in between texturing stages. Not that your monitor could display anything brighter than 1.0 anyway …

An addition for the overbright stuff:
You need to avoid the clamping in between texture environments. To do that you must either use some sort of pixel shader (or possibly other extension ) that allows passing values beyond the [0…1] range. Or you can simply first multiply with the lightmap, and then do the additive operations.

I thought I could do overbrighting by using extra multitexture, but my voodoo3 seems to be able to handle only two multitextures.

When MODULATE allows using shadows by doing Arg0 * Arg1, it doesn’t let lightmap colors go over the main texture colors, so no overbrighting (or whatever it’s called).

I can’t add 3rd multitexture for ADD becouse some (my) cards doesn’t support it.

Use GL_RGB_SCALE_ARB, and set the scaling to for instance 2. Now you’ll have something like a [0,2] range, sort of.

What do you mean about scaling? glPixelTransferf(GL_ALPHA_SCALE, 2.0f); (or whatever) ?

Originally posted by blender:
What do you mean about scaling? glPixelTransferf(GL_ALPHA_SCALE, 2.0f); (or whatever) ?

This: GL_ARB_texture_env_combine

Could you explain to me (I am a little new to extensions), is GL_ARB_texture_env_combine a whole new extension, or can I use it if my card just supports ARB_multitexture?

If I can, can I just directly use it’s definitions in glTexEnvi(…); or do I need some other function?

To use it your card must of course support the extension, there is an GL_EXT_texture_env_combine that works too, it only lacks a subtract option but is otherwise identical.

Do something like this:

glActiveTexture(GL_TEXTURE0_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glActiveTexture(GL_TEXTURE1_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);

I tried following code and results were that lightmaps weren’t drawn.

for(n=0; n<numFaces; n++)
{
pFace = &face[n];
pTextr = &texture[pFace->id];
pLmap = &lightmap[pFace->lid];

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, pTextr->texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
//glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glEnable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, pLmap->texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glEnable(GL_TEXTURE_2D);

glBegin(GL_TRIANGLE_FAN);
for(m=pFace->start; m<pFace->start+pFace->num; m++)
{
  if(pFace->flags != SKY)
  {
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, verts[m].tv.x, verts[m].tv.y);
    glMultiTexCoord2fARB(GL_TEXTURE1_ARB, verts[m].lv.x, verts[m].lv.y);
    glVertex3f(verts[m].pos.x, verts[m].pos.y, verts[m].pos.z);
  }
}
glEnd();

}
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

My graphics card doesn’t seem to support either ARB_texture_env_combine or EXT_texture_env_combine.

Still I can see overbrighting in some games like quake3 and blood2.

Hmm, what card do you have? EXT_texture_env_combine should be supported by at least TNT and up AFAIK.

Another possibility is to use multipass. First draw the base texture, then the lightmap with blending glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR). This will also be a scale by 2 (src * dest + dest * src = 2 * src * dest).

I have this damn Voodoo3 3000, which supports nothing. I’m planning to buy GeForce 2 this week.

How for example quake3 renders lightmaps with overbrighting on my machine? Multipass?

Do you mean that I should render first all the polygons with base texture, and then draw all the polygons with lightmaps. Fps will surely drop down badly.

If I can’t do overbrighting well with Voodoo, I’ll maybe just have to put It off from voodoo users.

If I’ll do as following:

If the graphics card supports only two multitextures, it uses them for regular lightmapping, and then uses also at the same time multipass for overbrighting.

If the card supports more than two textures, it uses 3rd for overbrighting.

I’m just wondering how does other games do overbrighting.

Originally posted by blender:
[b]If I’ll do as following:

If the graphics card supports only two multitextures, it uses them for regular lightmapping, and then uses also at the same time multipass for overbrighting.

If the card supports more than two textures, it uses 3rd for overbrighting.

I’m just wondering how does other games do overbrighting.[/b]

Howdy,

having seen the versatility of the color/texture combine operations in glide, the Voodoos must be able to support advanced texture environments which are needed for what you want to do.

Get your extension string, look for everything with texture_env in it. Then cross-check with the Extension Registry and see if some blending equations are useful to you. I know that the hardware can do that, and it would puzzle me if it wasn’t exposed somehow.