I am developing a software were PImages have to be displayed depending on MIDI messages. At runtime, when entering into draw(), some pictures are not displayed and some pictures are displayed after an operation on their hue: depending of the MIDI messages the hue changes. All displayed pictures are blended together in ADD mode (I want black to become transparent) and displayed in a "canvas", a PGrahics object which is sent to a Syphon server.
I first tried to apply the hue change using the loadPixels() and pixels[] of the PImage but it was to much work for the CPU. I also tried to use LUTs as suggested in this
post but it wasn't enough (the CPU exploses and each time I have pictures to display the framerate slow down around 20 fps). So I decided that the most powerful way to do the work was to go into glsl shaders... It is the first time I use it so I still miss a lot of experience !
After playing around with examples, tutorials and forum topics, I finally got a shader which does the hue operation very well (and it is very fast! I keep a good fps and it demands only 35% of CPU VS 70% before). The problem is that my blend mode is not working... the behaviour of my canvas is weird, with the same MIDI messages sometimes the pictures are blending, sometimes not, some pictures are not displayed...
I think that the blend shaders proposed
here are not what I need as they need two pictures (textures) as parameters but what I want is to blend the canvas into itself every time I draw a picture in it between beginDraw() and endDraw(). I read on the internet about openGL and the concept of buffering for blend modes but I am still confused with all of this. I also think that asking Processing to do the blend mode as there are operations on the PImages in the shader is not a good way to go (I tried this and it doesn't work), but I don't really know about blending in openGL, still learning!
So basically I am seeking a way to do my ADD blend mode as fast as possible (as after creating the image of the canvas I want to send it through Syphon + my system has to be fast and reactive to MIDI messages at runtime)
Does anyone have some clues / suggestions / tracks for me ? It would be great.