How do you apply Screen Subtraction without PIK?


#1

I love how screen subtraction works on the PIK node and am trying to recreate it so that I can use it outside of PIK. So the question is, how do you write an expression (SeExpr/SeExprSimple) that will subtract a screen the way PIK does? How then, do you premult the result?

I’ve surmised (1-a)*color1[0…2], where color1 are the RGB values of the screen sample area. I’m a bit confused by the results. How do I bring it home?

Any help would be appreciated.


#2

Everything is in the source code: https://github.com/NatronGitHub/openfx-misc/blob/d78e5b2066edcc0a696a2c0307bd7a058634dadf/PIK/PIK.cpp#L691

look for the output mode you want.


#3

Didn’t think to. Thanks for the lead.

The only line that looks like what I’m looking for is:

float v = fg[i] + c[i] * _despillBias[i] * (alpha - 1.);
out[i] = v < 0. ? 0 : v;

variable ‘v’ being the formula that I’m looking for. Am I correct?