I know glBlendFunc is the function call to specify a pixel blend mode.
I can do the Multiply Mode as in Photoshop, of which the formula is
C = A * B
where A is the source pixel, B is the destination pixel and C is final result.
Using glBlendFunc(GL_DST_COLOR, GL_ZERO) I'll get that effect.
So now my question is how to use the Screen Mode? The formula of it is:
C = 1 - (1 - A) * (1 - B)
Didn't check, but the way to go is as follows.
The built-in computation that OpenGL does looks like:
C = A*s + B*d
Where you can choose the s and d.
Some algebra gives us
C = 1 - (1 - A) * (1 - B) =
= 1 - (1 - B) + A*(1 - B) =
= A*(1 - B) + B
Let
s = 1 - B
d = 1
and we get the value we want. So this should work:
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With