7
$\begingroup$

On this question, When trying to overlay images using Alpha Over for green screen work , I used premultiply Alpha, it was the only option that would give me clean key without the background bleeding over. A comment states Never use that "Convert Premul" option on Cycles renders. Ever.

Why?

$\endgroup$
8
$\begingroup$

You misread the answer, and my suggestion wasn't terribly clear. Any imager should be "pro" associated (aka crap term "premultiplied") alpha.

There is a good reason, and I will expand this answer when I find some time later.

The bottom line is that only associated alpha models a real-world correlation, where unassociated doesn't.

Only associated alpha manages to model both occlusion and emission. Glows, convolutions, motion blurs, and a plethora of other transparent / translucent effects can only be modeled with associated alpha.

Think of alpha as selecting the over operation. The Alpha over node actually assumes associated alpha and performs the correct over operation, which is FG+(1-FG.a)BG.RGB.

Unassociated alpha can do none of these things. This is at least one of the reasons that PNGs are never used in a post production pipeline as they are incapable of using associated alpha. From the EXR Technical Introduction:

Calling the color channels “premultiplied” does not mean that the color values in an image have actually been multiplied by alpha at some point during the creation of the image, or that pixels with zero alpha and non-zero color channels are illegal. Non-zero color with zero alpha is legal; such a pixel represents an object that emits light even though it is completely transparent, for example, a candle flame or a lens flare.

In the visual effects industry premultiplied color channels are the norm, and application software packages typically use internal image representations that are also premultiplied.

http://www.openexr.com/TechnicalIntroduction.pdf

From the actual TIFF specification, regarding TIFFTAG_EXTRASAMPLES tag that denotes what type of samples are stored:

The difference between associated alpha and unassociated alpha is not just a matter of taste or a matter of maths.

Associated alpha is generally interpreted as true transparency information.

http://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html

Again, never, ever, use unassociated (crap term "straight" or "key") alpha, and instead associate it. This is what the unfortunately named "Convert Premul" does in the Alpha Over node. However, on direct Cycles renders, it is already associated and is never needed.

There is exactly one edge case that you must unassociate alpha before processing, and that is on colour corrections. To do so, you must be careful and divide all zero regions by a very small number as zero alpha with RGB nonzero is entirely valid, and represents an emission without occlusion.

The only time "Convert Premul" should ever be used is if the imager knows she is feeding it unassociated alpha, but like a good imager, she would never be using anything except the One True Alpha, associated alpha.

Further reading:

Zap Anderssen of Autodesk now: http://forums.cgsociety.org/archive/index.php?t-278718.html

Larry Gritz of OpenImageIO and Sony Pictures imaging team: http://oiio-dev.openimageio.narkive.com/aaTdld9U/handling-unassociated-alpha#post2

Jeremy Selan, two time Academy Award winning imager behind OpenColorIO, now at Valve: https://groups.google.com/forum/m/#!topic/ocio-dev/ZehKhUFqhjc

The Infamous Adobe Photoshop thread. Pay key attention to the names, as there are many imaging legends in it, including Zap Anderssen dismantling one of the head developers of Photoshop, only to have Florian Kainz of ILM back up Zap's take on it:

http://forums.adobe.com/thread/369637

EXR Technical Introduction:

http://www.openexr.com/TechnicalIntroduction.pdf

I likely misspoke in the original question as, from memory, I can't remember exactly what that goofy keying node delivers in terms of alpha. I suspect it is unassociated, which makes the "Convert Premul" option work. Generally however, to avoid oopsies in the code etc., it is prudent to manually associate your alpha and control the merging to prevent data loss in the RGB channels. I still stand by the advice, however; always try to maintain a consistent state of alpha, and when you deviate, do so under scrutiny.

$\endgroup$
  • $\begingroup$ I'm on the same page with troy_s regarding the use of misleading terms in programs UIs. This kind of questions are the result of a poor choice of terms for the functions. In this case, "convert premul" is a misleading label. Even the term "premultiplied" is misleading, as the very EXR specification states in the last page: It doesn't necessarily mean the plate was multiplied by the alpha. $\endgroup$ – Gez Feb 2 '16 at 21:09
  • $\begingroup$ What would the process with the very small number be like? Alpha += 0.00...1 > Unassociate > (e.g.) Gamma correct > Associate > Alpha -= 0.00...1 ? $\endgroup$ – Leander Apr 24 '18 at 13:33
  • $\begingroup$ Disassociate / Unpremultiply is a divide skip zero. That is, if the alpha is zero, leave the RGB values as-is, and multiply the RGB in the case of nonzero by 1/alpha or divide by alpha. To Associate / Premultiply, multiply not zero. That is, if the alpha is zero, skip and leave as-is, and multiply by alpha in the case of not. In a proper imaging pipeline, "gamma", or more usefully nonlinear transfer functions, should never be at play and you should only operate on linearized data, be it scene linear or display linear. Within Blender's compositor this is the case via transforms. $\endgroup$ – troy_s Apr 24 '18 at 17:41
-2
$\begingroup$

I believe it's that Cycles renders have straight alpha. Straight means that, even though the pixel is transparent, it still has pure, unaltered color information. Like R255 G35 B48 A10.

Converting straight alpha to premultiplied is essentially multiplying the color info with the alpha, so R255*(10/255) G35*(10/255) B48*(10/255) A10 becomes R25 G3 B5 A10.

If you tick 'Convert Premul' you're implying the Cycles render has already been premultiplied (which it hasn't) and Blender will try to readjust color values to accommodate that. The alpha rim gets wonky.

It's not that straight alpha is technically 'better' than premultiplied alpha. Premul alpha saves disk space so it's the preferred option for real-time 3D and like. It's just that the algorithms for combining straight and premul pictures are not compatible. My guess is that Blender prefers the straight variant, so you have the option to convert premul to straight if needed.

$\endgroup$
  • $\begingroup$ This is wrong. All raytracers model physical reality, and as such, unassociated alpha (aka "straight" or "key") can never be generated as it has no real-world counterpart. This is entirely incorrect, and alpha relationships are much more than a simple mathematical divide or multiplication. $\endgroup$ – troy_s Feb 2 '16 at 20:30
  • $\begingroup$ Just as troy_s, this is incorrect. It's exactly the opposite. Cycles renders associated (premultiplied) alpha. As it's already associated, the alpha over operation doesn't have to multiply the foreground * alpha again, so that's why you don't have to activate that checkbox for cycles renders. $\endgroup$ – Gez Feb 2 '16 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy