PDA

View Full Version : Specific blending mode (how to achieve this?)



gq3gq3
03-15-2010, 03:12 PM
Hey

Does opengl provide a blending mode, which would operate like this:
1)RGB values of destination and source are multiplied
2)Alpha values of destination and source are added

If not then how would you go about achieving that?

Thanks

dorbie
03-15-2010, 03:18 PM
You're asking for a blend equation multiply and it does not exist.

glBlendEquation does not support this. <<<< Edit to say this is bullshit

The simplest and probably fastest way is to render to texture and use multi-texture modulation

New HW and APIs have some programmable blend that should come to the rescue soon but not on most hardware out there now.

Depending on how specific your usage case is you could mask teh color buffers and output red channel as alpha and multiply destination by source alpha, then repeat for g and b.

Yann LE PETITCORPS
03-15-2010, 05:15 PM
You can certainly use a vertex shader for this ?

Alfonse Reinheart
03-15-2010, 05:58 PM
You can use glBlendFuncSeparate to give the RGB and Alpha different blending parameters.


You're asking for a blend equation multiply and it does not exist.

Sure it does:

glBlendEquation(GL_ADD);
glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ONE, GL_ONE);

dorbie
03-16-2010, 12:26 PM
You can certainly use a vertex shader for this ?



No, absolutely not.

dorbie
03-16-2010, 12:32 PM
You can use glBlendFuncSeparate to give the RGB and Alpha different blending parameters.


You're asking for a blend equation multiply and it does not exist.

Sure it does:

glBlendEquation(GL_ADD);
glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ONE, GL_ONE);

Sorry brain fart.

I've used DST_COLOR and SRC_COLOR for blending before so I was being a dumbass.

Thanks for the correction.

Dumb.

gq3gq3
03-16-2010, 01:16 PM
Thanks everybody, glBlendFuncSeparat did the trick