View Full Version : Blend textures with two passes...
10-18-2000, 09:38 AM
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?
10-18-2000, 10:29 AM
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.
10-18-2000, 10:55 AM
My code is like some this:
//second texturing pass
its seems not to work, I only see the secnd triangle texture without any blending...
can it be my graphics card error? (Matrox G400)
10-18-2000, 11:07 AM
Has blending been enabled with glEnable(GL_BLEND);?
10-18-2000, 11:08 AM
yes, the first line of the code is glEnable(GL_BLEND)
10-18-2000, 11:21 AM
DOH! (Guess I need glasses http://www.opengl.org/discussion_boards/ubb/rolleyes.gif )
Can you see the first pass if you comment out the second pass?
10-18-2000, 11:29 AM
yes, I can see the first pass if I comment the second one...
10-18-2000, 12:14 PM
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).]
10-18-2000, 03:00 PM
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
10-19-2000, 12:39 PM
Make sure your glDepthFunc is set to GL_EQUAL or else the second pass will bounce on the depth buffer test.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.