**[Walter Soyka]** *"Apparently Nuke does not use 1 - ((1-a) * (1-b)) for screen; instead, Nuke uses max(max(a,b), a+b-ab). This protects against errors over 1, but introduces the possibility of clipping the low end."*
I presented this last week without explanation. I'll dive in and show how you can do this in After Effects.

Here's a screen blend in action:

[image]

To perform Screen blending, you invert both inputs, multiply them together, then invert the result:

[image]

**a** and

**b** are our inputs. To invert something -- that is, to pivot the whole thing around middle gray (0.5), making white (1) into black (0), and black (0) into white (1), and also remapping all intermediate shades of gray, we can simply subtract the value of the input from white (1).

Inverting white (1-1) gives us black (0). Inverting black (1-0) gives us white (1). Inverting middle gray (1-0.5) gives us middle gray (0.5). Inverting a dark gray (1-0.25) will give us a light gray (0.75).

So, again, we invert both inputs

**a** and

**b**, giving us

**(1-a)** and

**(1-b)** to start with.

Then we multiply these together:

`(1-a) * (1-b)`

.

Then we invert the result -- that is, subtract it from 1:

`1 - ( (1-a)*(1-b) )`

We can build a screen in Ae with a few invert effects and the multiply blend mode:

[image]

If you go back to high school algebra, you may remember the technique for binomial multiplication: FOIL (first, outer, inner, last). Although our screen formula explains very clearly what it's doing, we can simplify it a bit mathematically.

`1 - ( (1-a)*(1-b) )`

1 - ( 1 - b - a + ab )

1 - 1 + b + a - ab

a+b-ab

That

**a+b-ab** should be familiar -- it's in the Nuke math I mentioned above. Let's look at the Nuke Screen math again:

`max(max(a,b), a+b-ab)`

The

**max** function means "take the larger of two values." So the Nuke Screen mode translates to English as follows: Take the larger of the larger of

**a** and

**b** and the result of a classic Screen.

More simply put, perform a classic screen, but if either input is brighter, use that instead.

There's already a simple max function in Ae -- it's the Lighten blend mode. That means we can roll our own Nuke-style Screen, by Screening A over B, then Lightening A and Lightening B over the results:

[image]

Using Lighten like this will preserve overbrights in float, but it will clip superblacks in one input if there is regular black (0) in the other, because max(0,-whatever) is always 0. You could use this double Lighten trick with the Add mode in float, too, to preserve overbrights and prevent subtraction on negative values.

Walter Soyka

Principal & Designer at

Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting

RenderBreak Blog - What I'm thinking when my workstation's thinking

Creative Cow Forum Host: Live & Stage Events