PDA

View Full Version : blending with glBlendFuncSeparate



soconne
11-03-2006, 03:53 PM
I have a quad with a color texture. Then I want to render the quad again but with a grayscale texture. I want the grayscale and color texture to blend together. But I also want to be able to control the amount of blending via an alpha texture. Basically texture splatting but blending the grayscale texture in the 2nd pass with what's already in the framebuffer.

I thought I could accomplish this by calling:
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

This way the color is srcRGB * dstRGB and the alpha is what's above. But I'm not getting what I need.

Does anybody know how to accomplish this using glBlendFuncSeparate or if its possible?

tamlin
11-03-2006, 04:13 PM
From what I understand, you want 2 RGB textures to be combined in a way defined by a third texture (alpha-only) by the wording "But I also want to be able to control the amount of blending via an alpha texture".

I suggest you have a look at texture env. combine (GL_COMBINE_ARB).

Just to be 100% clear: There is AFAIK NO way to accomplish separate alpha from any texture without at least this.

soconne
11-03-2006, 04:24 PM
Well what I'm trying to do is basically modulate a base texture and a detail texture together, and then control the amount of modulation by the alpha texture.

So basically something like this:

base * alpha + (base * detail * (1 - alpha)

I'm wondering if this is possible with just using glBlendFuncSeparate.

What I want to do is render the base texture in the first pass. Then in the 2nd pass render the detail texture along with its alpha texture and use the alpha texture for transparency, but blend the result with what's already in the frame buffer.