Blend textures with two passes...

I’m trying to make a terrain with two blended textures, now my idea is to make two rendering passes, the first with per example stone texture, and de second with another texture (grass), and I want that the RGB values of the second pass be added to the RGB values of the first pass depending on a factor (F)

R(final) = R(stone)*0.8 + R(grass)*0.2
G(final) = G(stone)*0.8 + G(grass)*0.2
B(final) = B(stone)*0.8 + B(grass)*0.2

which are the DTS and SRC parameters in the glBlendFunc?

For the second pass, set the fragment color to (1.0, 1.0, 1.0, 0.2). Make sure GL_MODULATE texture mode is being used. Set the source blend factor to GL_SRC_ALPHA and the destination blend factor to GL_ONE_MINUS_SRC_ALPHA.

My code is like some this:

glBlendFunc(GL_ONE, GL_ZERO);

//second texturing pass


its right?
its seems not to work, I only see the secnd triangle texture without any blending…

can it be my graphics card error? (Matrox G400)

Has blending been enabled with glEnable(GL_BLEND);?

yes, the first line of the code is glEnable(GL_BLEND)

DOH! (Guess I need glasses )
Can you see the first pass if you comment out the second pass?

yes, I can see the first pass if I comment the second one…

I’d surely think the G400 supports alpha blending, but it appears not to in this instance. You might want to double check that to see if it does. Or try to run the app using a different video card like a TNT or GeForce and see if the problem exists on them. That’ll narrow it down to either a hardware (or hardware driver) issue or a bug in the app.

I’ve since checked the G400 specs and they do claim to support all OpenGL blend modes.
So I’d now think it is either a bug in the OpenGL ICD, or a bug in the app. You certain you have the latest driver and ICD for the card? If so, then it is surely a bug in the app, somewhere.

[This message has been edited by DFrey (edited 10-18-2000).]

What is your glTexEnv settings? make sure you use something like GL_MODULATE on the second pass. If not, the alpha may be taken from the texture instead of the glColor value, and if your texture doesnt contain alpha information, I believe it will default to 1.0

Make sure your glDepthFunc is set to GL_EQUAL or else the second pass will bounce on the depth buffer test.