[Bf-compositor] use alpha premultiplication in linear Color Space?

Lukas Tönne lukas.toenne at gmail.com
Fri Apr 4 17:53:19 CEST 2014


The RGBA separate and combine nodes are fine IMO, they work just as
expected. What could be useful would be to extend the "Set Alpha" node with
an optional setting to handle premultiplication.

As discussed on IRC what happens is that, when replacing the alpha
component (either by "combine rgb" or "set alpha"), the rgb color
components are still premultiplied with the old alpha value, thus giving an
incorrect resulting associated color value.

input color: (r,g,b,a) = (R*a, B*a, G*a, a), where (R,G,B) is the
"original" unassociated color value
replacing alpha: (r,g,b,a') = (R*a, B*a, G*a, a') i.e. the resulting color
uses a wrong alpha factor for premul
desired result: (r',g',b',a') = (R*a', G*a', B*a', a')

Here's an example file that contains a node group which correctly replaces
rgb along with alpha to the desired premultiplied color:
http://www.pasteall.org/blend/28164

This node group would be the alternative "Set Alpha" implementation when
the proposed "premul" option is enabled.


On Fri, Apr 4, 2014 at 4:45 PM, Francesco Paglia <f.paglia.80 at gmail.com>wrote:

> After a discussion on blendercoders I understood why I had to add the
> premult node at the beginning and at the end of my nodetree.
>
> The fact is that combine and separate rgba do not take into account any
> property of the input.
> The separate don't know if an input have associated or unassociated alpha
> and the combine strictly act as a "container of independent channels" that
> have to be further recombined.
> This drive to the need of unassociate the alpha at the beginning of the
> tree and to reassociate it at the end of the modification of the alpha
> channel to make it properly working.
>
> I got confused because after combining the channels previously separated I
> have not get any of the result I could expect but an image equal to the
> original...
> Here what I could expect:
>
> 1° the correct image with a lower alpha intensity
> 2° an image with a lower alpha and black artifact
> 3° a fully opaque rgb image (equal to the orginal but with black color
> where the alpha should be) with an unassociated alpha
>
> Since non of those result came up to me I started thinking in a wrong way
> that lead me to write the original post.
> After a bit of discussion most of the question have been solved but after
> further thinking and with the discussion in mind I'm even more convinced
> that with my setup I should have get the third result.
>
> I think there's still some issue in the combine rgba node.
>
>
>
> 2014-04-04 14:37 GMT+02:00 Francesco Paglia <f.paglia.80 at gmail.com>:
>
> Hi Ton,
>> let me say I used the term Fade because I was used to it coming from
>> other Compositing packages.
>> I mean the value of a pixel of a channel multiplied by another value
>> should output the result of the multiplication .
>> Alpha over comes later... after this operation!
>>
>> I think an image would explain much more than 100 words especially if my
>> jargon isn't really appropriate :)
>>
>>
>> https://lh4.googleusercontent.com/-f-dm0O5h_qs/Uz6nQz4s9qI/AAAAAAAAI14/CsFT1RmOzmw/w1358-h309-no/noprem.png
>>
>>
>>
>>
>> 2014-04-04 13:45 GMT+02:00 Ton Roosendaal <ton at blender.org>:
>>
>> Hi,
>>>
>>> "Fade" can mean too many things.
>>> You mean: "Image should become transparent - during an alpha-over
>>> operation"?
>>>
>>> Well to start with - such effects look much different in linear, than in
>>> non-linear spaces.
>>>
>>> And realize: premultiplied RGBA = alpha should not be changed. Not!
>>> Straight alpha - yes, that you can do with what you like.
>>>
>>> -Ton-
>>>
>>> --------------------------------------------------------
>>> Ton Roosendaal  -  ton at blender.org   -   www.blender.org
>>> Chairman Blender Foundation - Producer Blender Institute
>>> Entrepotdok 57A  -  1018AD Amsterdam  -  The Netherlands
>>>
>>>
>>>
>>> On 4 Apr, 2014, at 13:25, Francesco Paglia wrote:
>>>
>>> > Hi, hope I used a right title for this topic.
>>> > I've just setup a simple nodegroup to make a fade node.
>>> > Here the tree:
>>> >
>>> >
>>> https://lh4.googleusercontent.com/-Mos7IL6bx4E/Uz6VHnKqZ3I/AAAAAAAAI1U/zJJ7zOFnRWQ/w1176-h368-no/fade_nodesetup.png
>>> >
>>> > As input of this group I've a renderlayer, if I'm not wrong the
>>> compositor works with a linear workflow so why I have to add make alpha
>>> straight at the beginning and a premultiply at the end to make it working
>>> properly?
>>> >
>>> > Thanks for your help
>>> > Francesco
>>> >
>>> > --
>>> > Francesco Paglia
>>> > Vfx and Production Supervisor
>>> >
>>> > mobile  +39 347.82.12.473
>>> > e-mail   f.paglia.80 at gmail.com
>>> >
>>> > _______________________________________________
>>> > Bf-compositor mailing list
>>> > Bf-compositor at blender.org
>>> > http://lists.blender.org/mailman/listinfo/bf-compositor
>>>
>>> _______________________________________________
>>> Bf-compositor mailing list
>>> Bf-compositor at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-compositor
>>>
>>
>>
>>
>> --
>> Francesco Paglia
>> Vfx and Production Supervisor
>>
>> mobile  +39 347.82.12.473
>> e-mail   f.paglia.80 at gmail.com
>>
>>
>
>
> --
> Francesco Paglia
> Vfx and Production Supervisor
>
> mobile  +39 347.82.12.473
> e-mail   f.paglia.80 at gmail.com
>
>
> _______________________________________________
> Bf-compositor mailing list
> Bf-compositor at blender.org
> http://lists.blender.org/mailman/listinfo/bf-compositor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-compositor/attachments/20140404/9db445f5/attachment-0001.htm 


More information about the Bf-compositor mailing list