adding a layer as a "screen" bleding mode

JesterN's icon

Hi all, is there a way of using jit.op to have a layer covering completely whatever is underneath excluding where it's black?
I have some video with white parts and would like to have some red stripes for example on top. So i create those on a black background, but of course when i add them to white they produce white. If i multiply is ok but in the black parts of the upper layer the result is black of course erasing the first layer. So what kind of operation should i use?
Thanks
A

Secip Xynic's icon

Look into [jit.alphablend], if I understand you correctly, then that is what you need. If you have the red stripes on a black background, use [jit.matrix 4 char (width) (height) @ planemap 1 1 2 3] to duplicate the R plane onto the A plane, then send it to the left inlet of [jit.alphablend] and your original video to the right.

This will result in all the red stripes entire blended with the original matrix. If you only need them where the white parts are, you might want to perform additional operations on the alpha channel of the remapped matrix.

JesterN's icon

thanks a lot i'll try that
A

Secip Xynic's icon

If you have trouble figuring it out, maybe post the patch...

Rob Ramirez's icon

according to this website the equation for Screen mode is:R = 1 - (1-Base) × (1-Blend)

Max Patch
Copy patch and select New From Clipboard in Max.

this can easily be achieved with standard jit.op operators, but this is a perfect task to try out jit.gen/jit.pix/jit.gl.pix.

JesterN's icon

actually i made a mistake and i need "hard light" so that red on both black and white i visible, but i see how to implement it now.. thanks Robert
and Secip Xynic
A

JesterN's icon

Somehow i still find troubles having an if in jit.op (i have no max 6 yet). In the next patch i'm trying to have the red text both on the white and on the black...

3609.ScreenBlending.maxpat
Max Patch
Lance Green's icon

Thank you,cause i have the same question.thanks