How do you apply Screen Subtraction without PIK?


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.


Everything is in the source code:

look for the output mode you want.


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?