Blending

Just starting with opengl and I had a question about multitexture blending.

More or less what I want to do is take two textures combine them using the alpha values. Then modulate the combined textures with the polygon color. This seemed simple at first but I’m having a little bit of trouble. The closest I’ve gotten is by setting the first texture to modulate. However if I set the second texture to modulate it mixes with the first and changes the firsts alpha. Neither of which I want. If I set it to decal it is drawn on top but it doesn’t blend with polygon color.

I’ve changed everything from the GL_sources to Operands. I just can’t seem to make it work.

One idea that did come to mind was to use the glsecondarycolor. But the only option that I’ve seen for that is add, not modulate like I want.

Thanks, hopefully that makes sense.

NeHe Tutorial #8

Thanks for the reply, but I understand the basics of blending. I’m looking for something a little more specific.

Besides the method I described above the closest I can come is…

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
ogl_bindbmtex(bmbot);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
					
		glActiveTextureARB(GL_TEXTURE1_ARB); 
		glEnable(GL_TEXTURE_2D);
		ogl_bindbmtex(bm);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
								glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
		glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1);
		glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PREVIOUS);

This way the top texture is modulated correctly, but everything else is invisible. Probably because the alpha’s are modulated together.

ogl_bindbmtex() is equivelent to glBindTexture.

What about fragment shaders/programs?

Those (for me, at least), are a much simpler way conceptually to do things than texture combiners…

Edit: Which makes it easier to get the results you want/expect, because it can be programmed in a more readable/legible format…

CJ

The thing about those is that I’ve never worked with them before. Sounds like I have to learn something new. What is the minimum hardware that can run those. I assume if hardware doesn’t support it, it would run in software right?

I’ve never worked with them before, either.

The nice thing, though, is that there’s a fairly small body of material to cover, counting extensions specifications etc.

Plus, they’re convenient, they put all your effects in one place.

Hardware varies, anything fairly recent should have some kind of shader support, at least sufficient to do what you want…

Generally reverts to SW, though that may be driver dependent.

CJ