iphoneopengl-esscreenframebufferglblendfunc

How to do something like Photoshop's screen Blending with glBlendFunc (OpenGL ES 1.x)?


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?


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.