Photoshop blend modes

Hi there,

Flash dev who’s just started learning C++ and OF (practically a few days ago) - loving it so far!

I’m looking to recreate the effect of Photoshop style blend modes (overlay, multiply, etc) in OF.

From what I’ve gathered thus far - you can easily set alpha with OF methods, but for more advanced blending you need to make direct GL calls. E.g.

  
glEnable(GL_BLEND);		  
// enable "screen" blending  
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);		  
// draw stuff here  
glDisable(GL_BLEND);  

Now… is it possible to achieve the other more common Photoshop blending modes in a similar fashion, passing different arguments to glBlendFunc?

I’ve stumbled across this-post which talks about achieving Photoshop blend modes with a GLSL shader. Is this relevant to what I’m trying to achieve?

Do you achieve Photoshop blend modes through the use of a shader, or am I just missing something completely obvious? Also, are there any simple examples out there that utilise blending modes?

Thanks in advance!

Although this wiki is in german, the examples show how the different modes work :slight_smile:
http://wiki.delphigl.com/index.php/glBl-…-#Beispiele

Maybe that will help a bit
Greets
Snoogie

The full set of Photoshop blend modes are probably most easily done using shaders, but OpenGL has its own blending modes so you should check them out first.

Here’s a little more info:
http://stackoverflow.com/questions/8182-…-ut-shaders
http://www.gehacktes.net/2010/01/alphab-…-th-opengl/

Thank you both for those helpful links, much appreciated :slight_smile:

Thanks :lol:

Hello all

I think this addon is useful for this topic.
https://github.com/Akira-Hayasaka/ofxPSBlend

Hi Akira, thanks for sharing this. It compiles fine on my macbookpro, but the visual output is random garbage instead of the expected output, when using BlendColor the garbage is even animated!

Could it be that the lowly ATI X1600 does not support a feature needed for this?

Do you see any errors coming from the ofShader compilation process? If not, it should work ok, since this is using GLSL 1.2 and not doing anything particularly tricky. You could check your card with the OpenGL extensions viewer here: http://www.realtech-vr.com/glview/ Look for what GLSL version is supported.

Phew, found an old version that could be downloaded w/o an app store account. Shading version 1.20, seems OK.
I don’t get errors (it compiles) but a bunch (24 in debug, 16 in release mode) of warnings similar to this one:

ld: warning: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, int> > >::allocate(unsigned long, void const*)has different visibility (hidden) in /Users/Robotfunk/Documents/_dev/of_preRelease_v007_osx-1/libs/openFrameworksCompiled/lib/osx/openFrameworksDebug.a(Exif.o-i386) and (default) in /Users/Robotfunk/Documents/_dev/of_preRelease_v007_osx-1/libs/openFrameworksCompiled/lib/osx/openFrameworksDebug.a(ofTexture.o)

In some blendmodes I can vaguely make out the shape of the head in the noise, so the images seem to get loaded allright.

Great info here, thanks to all ! :slight_smile:

@rypon - OF has PS blend modes too (screen, add, etc.):
EX: ofEnableBlendMode(OF_BLENDMODE_MULTIPLY); … ofDisableBlendMode();
https://github.com/openframeworks/openFrameworks/pull/310

@Akira - I just finished my project, but could have saved sometime with your addon! :wink:

@snoogie - Danke ! No problem w/language, the “Beispiele” section shows an excellent image example !

Attached image from my project using ofxOpenCv // operator*= // glTexEnvf GL_REPLACE & GL_BLEND:
( maybe not the best approach, but it seems to work, still learning! :wink: )