Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

This worked for me for Straight alpha.

  • RGB source = SRC_ALPHA
  • alpha source = SRC_ALPHA
  • RGB destination = ONE
  • alpha destination = ONE_MINUS_SRC_ALPHA
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top