Photoshop normal blend formula


I'd like to know the blend formula that Photoshop uses in it's Normal blend mode. Any documentation I find it says it replaces the layer's color by the brush color, which is true but nowhere does it say what happens with the alpha value.

For example, when I paint with magenta (255,0,255) with a 50% opacity and then paint cyan (0,255,255) also at 50% opacity on top of it, I get 85,170,255 with an alpha value of 0.75 as a result color. So obviously opacity of the brush color has a stronger influence than the opacity of the layer.

Just like the other blendmodes the Normal one has to have a formula to calculate the final color, does anyone know it?

Thanks in advance
Who is Participating?

Improve company productivity with a Business Account.Sign Up

tomaugerdotcomConnect With a Mentor Commented:
Normal blend mode is a straight function of colour replacement multiplied by the opacity factor.

The formula remains the same regardless of whether we're talking about a Brush being applied to a layer, with the Brush blend mode; or a second Layer overlaying the first layer with the Layer Blend mode set to Normal.

(RGB1 * (100% - opacity %)) + (RGB2 * opacity %) = RGB

Note that if you test this out in Greyscale mode, the numbers don't seem to add up because it's using the K value (0 - 100%) not the equivalent RGB value. Which is odd, but there you go.

And of course, for CMYK the formula is again based on the CMY and K channels, and results may be different (which is why we always work in RGB - EVEN when the job is going to go to print: you convert to CMYK AFTER you've flattened your final production image, never before).

tomaugerdotcomConnect With a Mentor Commented:
In re-reading your question, I wonder whether you're not making a classic misconception about how Brush opacity works.

Brush opacity works the same as layer opacity EXCEPT that RGB1 (the underlying "layer") is whatever is on the current painting layer SINCE THE LAST BRUSH STROKE. In other words, every time you release the mouse button, Photoshop does a "mini-flatten" of your painting layer.

Thus, if you have a white layer to start with, then grab Red with an opacity of 50%, the resulting colour is pink because it's 50% white and 50% red.

Then when you release the mouse button, Photoshop forgets all about that opacity and sees the new "flattened" layer as pink with 100% opacity.

So when you now choose green with 50% opacity and draw a brush stroke over the pink stroke the colour you get is a muddy green because it's 50% green + 50% pink.

SnapplesAuthor Commented:
I'm sorry I took so long to respond, I've been busy with work related things and forgot about this thread.

Thank you for the formula. I didn't know whether Photoshop used the formula for regular alpha blending, premultiplied alpha blending or something else entirely.
I'm writing a painting app for a smartphone and I'd like to get the same behavior as one would get in Photoshop, and with your formula I do. So thank you.

Also thank you for that second post, it made me realise I had made a mistake, I was drawing the brushstroke to the layer every frame (about 30 times per second), rather than once every time the mouse is pressed and released. So I fixed it by drawing on a temporary layer from the moment the user taps the screen until he releases it and then flatten it with the layer below it.
SnapplesAuthor Commented:
Thank you, everything I needed to know.
Right on, Snapples, good luck with the app! Sounds cool.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.