![]() |
|
The workings of glBlendFunc |
Rob Fletcher
Member #2,830
October 2002
![]() |
Hello, I'm a little confused, and I'm having trouble googling my troubles away. I'm getting into some of OpenGLs blendy abilities, so glBlendFunc has become of interest to me. There is no shortage of the manual out there, but I don't quite get something. I think what I'm not understanding is what color scaling is all about. At least, why there would be two of them. In my brain, I see blending as having a function that takes the new and the old colors, does stuff to them, returns the output color. Functions are like 'add', 'screen', etc... Yet, glBlendFunc asks for two parameters, and I can't seem to understand it. Could somebody please explain to me (or maybe link to something with a good explanation) glBlendFunc's two parameters and how they affect the blending? Thanks! Rob |
James Howard
Member #262
April 2000
![]() |
sfactor is the source colour manual said:
sfactor: dfactor:
e.g. if you call glBlendFunc(GL_ONE, GL_ONE), and ---- |
gillius
Member #119
April 2000
|
I believe it does "s * s_fac + d * d_fac", where you give it s_fac and d_fac. In the previous post, GL_ONE was used, so it became s+d, or an additive blend. Gillius |
Krzysztof Kluczek
Member #4,191
January 2004
![]() |
Yes, OpenGL blending takes source and destination colors, multiplies them by something and then adds them. glBlendFunc specifies what those colors should be multiplied by. Possible modes:
where ### can be: Note that OpenGL some combinations may not work, like multiplying color by itself. Examples: ________ |
Rob Fletcher
Member #2,830
October 2002
![]() |
Ah! It all clicks now. Thanks guys. Sometimes when my brain isn't in math-mode I forget the implications of the term "factor". It makes good sense now, thanks! Rob |
Bob
Free Market Evangelist
September 2000
![]() |
Quote: Note that OpenGL some combinations may not work, like multiplying color by itself.
Unless NV_blend_square is supported, of course -- |
|