Reputation: 16618
I have a simple one channel (8bit) bitmap with luminance data only, and I want to blend it with the existing framebufer like Screen blending mode does it in Photoshop.
So the source's white pixels (255) should result white, source's 50% gray pixels (128) should result the framebuffer pixel enlighted by 50%, and source's black pixels should leave the result alone. Do I have to set glColor4f as well?
Can some glBlendFunc expert of you help me here?
Upvotes: 3
Views: 5178
Reputation: 86085
This worked for me for Straight alpha.
SRC_ALPHA
SRC_ALPHA
ONE
ONE_MINUS_SRC_ALPHA
Upvotes: 0
Reputation: 3446
Screen blending is C = S + (1 - S) × D, so what you want is glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR)
. If you ever introduce an alpha channel, you should still be able to get correct results if you keep your image data in premultiplied format.
Upvotes: 11