Combining RGB with alpha from other TMU?

Hi all, this is my first post here!

I’m looking for information on how to use two texture units to do both GL lighting and per-vertex alpha.

One texture has RGB information, but no alpha. The other texture has only alpha information. I want to copy the alpha from the second texture to the first with a combine operation. I want to change the alpha region every time, so I cannot simply use an RGBA texture.

I’d like to do this since it’s not possible to use vertex color alpha at the same time as lighting.

I’m not to famliar with the multitexturing parts of GL so any pointers on what combine modes I’d have to use would be most welcome.

Thanks,
dep.

hi,

you should use the arb_texture_env_combine extension, it’s very simple to use, and your problem will be resolved quickly.

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_combine.txt

Arath

Thanks, this was what I was looking for.

This is what I am using right now:

glActiveTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);

If I understand this correctly, the first TMU will generate fragments just like normal. The second TMU will leave the incoming RGB values with themselves (REPLACE with SOURCE=PREVIOUS) and replace the incoming alpha values with the alpha from the its own texture.

I can’t get it to work with a GL_ALPHA-format texture on the second TMU though. It only seems to work with an RGBA texture or a GL_LUMINANCE_ALPHA texture.

Any ideas on that?

Also, it seems kind of wasteful to replace each incoming RGB value with itself. AFAIK there is no LEAVE_ALONE option, but that would be nice… :slight_smile: