View Full Version : glBlendFunc settings to get a modulated effect?

01-12-2003, 01:13 PM
I HATE working with glblendfunc, i find it so confusing. If i use multitexturing, i simply leave the texture mode set on modulate, and it creates the effect i want. My question is if i want to do this effect (Just modulate the current color, with the incomming) using glBlendFunc(); what settings should i use inside of the blend func??

01-12-2003, 02:02 PM
I agree that the blend function can be a little bit confusing, but once you learn it... yeah... you know what I mean.

The blend function is (Cs * Fs) + (Cd * Fd). Subscript s is for source, and d for destination. C is color and F is factor. So, for example, Cs is the incomming color, and Fd is a factor that is miltiplied with the destination color.

You want to multiply Cs and Cd. This can be achieved by setting Either Fs = Cd or Fd = Cs. Let's pick the first, which is done by setting it to GL_DST_COLOR. We now have the equation (Cs * Cd) + (Cd * Fd).

We don't want anything more than the first part of the formula, so we set multiply Cd by zero; GL_ZERO.

The resulting formula is glBlendFunc(GL_DST_COLOR, GL_ZERO). You can also set it fo glBlendFunc(GL_ZERO, GL_SRC_COLOR). I leave it to you, as an excersise, to figure out hiw that one works.

01-13-2003, 03:39 AM
Thank you very very much, that is the BEST anyone has ever explained the blend function to me. I compleatly get it now. Many thanks.