Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Photoshop blending mode to OpenGL ES without shaders

I need to imitate Photoshop blending modes ("multiply", "screen" etc.) in my OpenGL ES 1.1 code (without shaders).

There are some docs on how to do this with HLSL:

  • http://www.nathanm.com/photoshop-blending-math/ (archive)
  • http://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/

I need at least working Screen mode.

Are there any implementations on fixed pipeline I may look at?

like image 897
Alexander Gladysh Avatar asked May 03 '09 22:05

Alexander Gladysh


People also ask

How do you change the blending mode in Photoshop?

How To Change The Blending Mode in Photoshop? To change a Layer Blending Mode, you can go to the unlabeled dropdown on the top left of the Layers panel and choose another blending mode for the currently active layer. By default, all Layers are set to Normal, and groups are set to Pass Through.

Is overlie a blending mode in Photoshop?

As we saw at the very beginning of our discussion, the Overlay mode is part of the Contrast group of blend modes, along with other blend modes such as Soft Light, Hard Light, Vivid Light, Linear Light, and so on.

How do you change the blending mode of a layer?

Modify a layer's blend modeIn the HUD, click the Blend Mode pop-up menu, then choose a different mode. In the Properties Inspector, click the Blend Mode pop-up menu, then choose a different mode. Choose Object > Blend Mode, then choose a different mode from the submenu.


1 Answers

Most photoshop blend-modes are based upon the Porter-Duff blendmodes.

These requires that all your images (textures, renderbuffer) are in premultiplied color-space. This is usually done by multiplying all pixel-values with the alpha-value before storing them in a texture. E.g. a full transparent pixel will look like black in non-premultiplied color space. If you're unfamiliar with this color-space spend an hour or two reading about it on the web. It's a neat and good concept and required for photoshop-like compositions.

Anyway - once you have your images in that format you can enable SCREEN using:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR)

The full MULTIPLY mode is not possible with the OpenGL|ES pipeline. If you only work with full opaque pixels you can fake it using:

glBlendFunc(GL_ZERO, GL_SRC_COLOR)

The results for transparent pixels either in your texture and your framebuffer will be wrong though.

like image 130
Nils Pipenbrinck Avatar answered Sep 27 '22 19:09

Nils Pipenbrinck