Geri Borbás
Geri Borbás

Reputation: 16618

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?

Upvotes: 3

Views: 5178

Answers (2)

eonil
eonil

Reputation: 86085

This worked for me for Straight alpha.

  • RGB source = SRC_ALPHA
  • alpha source = SRC_ALPHA
  • RGB destination = ONE
  • alpha destination = ONE_MINUS_SRC_ALPHA

Upvotes: 0

Pivot
Pivot

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

Related Questions