## Contracting Alpha? (Send Help)

Moderator: SecondMan

Ayush Bakshi
Posts: 15
Joined: Wed Jan 23, 2019 8:59 am
Been thanked: 2 times

### Contracting Alpha? (Send Help)

Hi Everyone! I didn't thought that I'll ask for help this frequently..

For some reason.. the Alpha of my multipass render seems to be off (expanded) by 1-2 pixel.. I can't for the life in me find how to contract it
Things I tried:

0. Internet... (excluding this forum, obviously )
1. Matte Control : Played with 'Contract/Expand', Blur, Gamma.. It does work but only after blurring it. And it never contracts beyond what I already have even after entering insane values.
2. Dilate/Erode : Pretty much same as Matte Control.
3. Taking some time off..
4. Banging my head on the nearest wall (JK)

Why are things that looks so simple have to be so hard to execute. If it were photoshop then it's just a matter of Minimum/Maximum filter. I can achieve the result just by editing in PS and importing back but.. We all know that's a workaround. There's some obvious solution escaping my eyes which will make me feel stupid when unearthed

Thanks again!
Gotta sleep.. (we need 'sleepy snot' emoji)

Tags:

SirEdric
Fusionator
Posts: 1564
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 45 times
Contact:

### Re: Contracting Alpha? (Send Help)

Sorry for asking the obvious, but could it be that your RGB channels are simply not multiplied with the Alpha?
What happens if you just add a MatteControl and set it to 'multiply image'?

intelligent machine
Fusionista
Posts: 341
Joined: Fri May 13, 2016 10:01 pm
Location: Austin, Texas, USA
Been thanked: 16 times
Contact:

### Re: Contracting Alpha? (Send Help)

There's also the super handy "AlphaMultiply" tool.

SecondMan
Posts: 3104
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 23 times
Contact:

### Re: Contracting Alpha? (Send Help)

And it always helps to post an actual example...

What's the sleepy snot emoji??

Added in 1 minute 6 seconds:
is it this one?

Ayush Bakshi
Posts: 15
Joined: Wed Jan 23, 2019 8:59 am
Been thanked: 2 times

### Re: Contracting Alpha? (Send Help)

SirEdric wrote:
Wed Mar 13, 2019 12:42 pm
Sorry for asking the obvious, but could it be that your RGB channels are simply not multiplied with the Alpha?
What happens if you just add a MatteControl and set it to 'multiply image'?
Yeah.. This was the case.

↓ That's a lot of text.. Preparing a comprehensible image. (Done! Link in the end)

I was using two matte controls..
One was getting input (bg) from the alpha pass and contracting it (which didn't worked until I chose 'post multiply image').
Used first one's output for the effect mask of 'blur' node. First one was also outputting that alpha to another matte control which was 'Solid matting' it's input (final composition with white edge). I ticked 'post multiply image' on 2nd Matte Control too.. and thought that thing will just work. But it didn't (first one was working.. 2nd was not. BUT.. then I switched input (1st Matte Control's output) to Garbage Mask and inverted which did the trick..
I think things could be done much more streamlined way and I did something wrong..

↑ That's a lot of text.. Preparing a comprehensible image. (Done! Link in the end)

Thanks!

Added in 2 minutes 23 seconds:
SecondMan wrote:
Wed Mar 13, 2019 3:22 pm
And it always helps to post an actual example...

What's the sleepy snot emoji??

Added in 1 minute 6 seconds:
is it this one?
Yeah.. my bad.. Will keep that in mind.

Yup →← this one. Should be in forum's given emojis.

Here's the problem and project ↓ (check files '6. White Edge Problem' and 'White Edge Problem Project' [35 MB])

While you guys are at it.. You're free to give me feedback on this project (final composition in zip file).

gez
Fusioneer
Posts: 109
Joined: Mon Jul 16, 2018 6:21 pm
Location: Argentina
Been thanked: 13 times
Contact:

### Re: Contracting Alpha? (Send Help)

Hi,
I've been skimming through your composition and I can spot several problems.
I'm not going to pin-point exactly what's causing your edges because it's not a single place but rather a sum of errors accumulated through the flow. So this is what I'd do:
First things first, try to reconstruct the beauty (which is correct as it doesn't have any light fringe around and blends ok over the background). Forget color correction, just focus on recreating the beauty appearance. It should be 1:1
Make sure you're using the right operations for each pass: lighting passes are additive, colour passes are multiplicative. Keep track of alpha channel in each step. When you're combining passes together alpha can be left alone, so focus on getting a clean RGB composite of all the passes, then assign the alpha channel. That way it should be easier to track what's going on with your edges. At any rate, avoid using alpha-over for compositing passes.
In theory compositing all the passes back to beauty doing RGB alone should give you a proper associated (premultiplied) plate, so alpha channel should be copied via a channel boolean op.
In short, before worrying about integrating the foreground in terms of colour just make sure your passes are composited properly.
For the colour I'd go for a grading pass AFTER the compositing of passes, predividing the foreground plate and adjusting through a primary and some isolated secondaries using the clown pass).
Also it would be a good idea to keep an eye on your flow layout. It's a tad messy and it gets a bit difficult to follow, specially when you have to hand your composite over to other people

gez
Fusioneer
Posts: 109
Joined: Mon Jul 16, 2018 6:21 pm
Location: Argentina
Been thanked: 13 times
Contact:

### Re: Contracting Alpha? (Send Help)

Hi, I played a little with your composition and re-arranged some stuff.
First, I tried to recreate the beauty by blending the passes together.
I broke down the shading in two groups: diffuse (adding direct and GI passes together and multiplying by albedo) and glossy (adding the reflections and speculars). Then added the two groups.
That recreated the appearance of the beauty reference 1:1
I left the grading to the end, just using the ID passes to mask secondaries.
Once I had the passes properly composited and matching overall colour I added some finishing touches to integrate better with the background plate:
- blurred the wood texture in the albedo using the corresponding id pass to merge with the original
- blurred the reflections to make them less detailed
- adjusted the reflections on the legs, the filtering had a texture that was too strong.
- added some filtering (blurring then sharpening) and grain.

I did this test because it was fun to do but also to show you an example of a simplified and more readable flow. Also it shows that you don't need to contract your alpha to avoid fringes if your passes are composited properly.
I hope it helps.
Maac Chair007_test-2.comp
btw, a couple of things to keep in mind:
When you composite over a background plate with an over, the bitdepth of the resulting image will be the one defined by the backplate. Yours was set to format loading a jpeg, meaning that everything was being composited at 8 bit integer. Always remember to move your bg images at least to 16 bit float to avoid quantization artifacts.
You don't need alpha set in your passes. You can just skip it and load only the channels you need (in this case, compositing only RGB passes it's enough to set only the contents for R, G and B.

You do not have the required permissions to view the files attached to this post.

Ayush Bakshi
Posts: 15
Joined: Wed Jan 23, 2019 8:59 am
Been thanked: 2 times

### Re: Contracting Alpha? (Send Help)

gez wrote:
Mon Mar 18, 2019 8:39 pm
Hi, I played a little with your composition and re-arranged some stuff.
First, I tried to recreate the beauty by blending the passes together.
I broke down the shading in two groups: diffuse (adding direct and GI passes together and multiplying by albedo) and glossy (adding the ................................................ You can just skip it and load only the channels you need (in this case, compositing only RGB passes it's enough to set only the contents for R, G and B.

I can't believe that someone spent time on my silly mistakes. Thanks for all the tips and showing the proper workflow. I was happy in ignorance that my work in this project is done. But now I'm happier that all my doubts are cleared (Redoing this composite properly now).

I thought that it was okay for composite and beauty pass to mismatch a little (because I never got them 1:1 ) but since you showed that it could be done with the render elements I have.. I'll redo this from ground up.

One thing though.. There's no 'Add' or 'Linear Dodge' and light passes should be 'added' so in my project what I did was to set Alpha gain to zero (dunno exactly what it is but I read that it's equivalent to 'Add') Was that right approach. Checking the corrected comp now.

Thanks again.. We need a way to give more 'Thanks' than one in this forum

Added in 6 minutes 43 seconds:
Ayush Bakshi wrote:
Tue Mar 19, 2019 4:18 am
..........One thing though.. There's no 'Add' or 'Linear Dodge' and light passes should be 'added' so in my project what I did was to set Alpha gain to zero (dunno exactly what it is but I read that it's equivalent to 'Add') Was that right approach. Checking the corrected comp now......
Oh! I get it. By using channel boolean. I was finding 'Add' in merge node.

Midgardsormr
Fusionista
Posts: 918
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 22 times
Contact:

### Re: Contracting Alpha? (Send Help)

Ayush Bakshi wrote:
Tue Mar 19, 2019 4:25 am
There's no 'Add' or 'Linear Dodge' and light passes should be 'added' so in my project what I did was to set Alpha gain to zero (dunno exactly what it is but I read that it's equivalent to 'Add')

The basic formula going on in an additive Merge (this is sort of optional knowledge, but I have found it useful several times) is:
RGBfg + RGBbg * (1 - Afg) = RGBresult

Alpha Gain is a multiplier on the Alpha channel, thus:
RGBfg + RGBbg * (1 - Afg*Gain) = RGBresult

So when Gain is reduced to 0, you get 1 - 0 = 1, and therefore the equation becomes RGBfg + RGBbg = RGBresult

You might have noticed the qualifier "additive" up there. The Merge node also has a slider called Subtractive -- Additive. That slider can be used to change the mode of the Merge to handle elements that are not premultiplied. It makes the foreground part of the equation a little bit more complex: RGBfg * Afg * gain +

In that scenario, turning Alpha Gain down not only allows the Background to show through more, it also darkens the Foreground. The result is identical to using the Blend slider.

Knowing the actual formulae isn't something that most compositors really need but sometimes understanding what's going on 'under the hood' can be helpful for troubleshooting a problem in a composite.

Ayush Bakshi
Posts: 15
Joined: Wed Jan 23, 2019 8:59 am
Been thanked: 2 times

### Re: Contracting Alpha? (Send Help)

Midgardsormr wrote:
Tue Mar 19, 2019 8:24 am
Alpha Gain is a multiplier on the Alpha channel, thus:
RGBfg + RGBbg * (1 - Afg*Gain) = RGBresult

So when Gain is reduced to 0, you get 1 - 0 = 1, and therefore the equation becomes RGBfg + RGBbg = RGBresult
Perfect! I like seeing under the hood. Been watching Simon Ubsdell's videos →
(How to NOT have this preview??)

Your articles are like bible for Fusion. Thanks for writing them.

Another piece of puzzle left for me (for now ) is do we still need to sandwich CC and color altering nodes between gamut nodes?
I mean when I'm working in linear workflow (I rendered this chair in 32 bit exr) I put a gamut node before (output - srgb, add gamma) and one after (input - srgb, remove gamma) the CC node. Am I doing things wrong? I read somewhere that Fusion's CC node expects srgb input. Is it still true (Fusion 9)? And if it is true then do we have some list of tools that expect srgb?
(My viewers remain at LUT - sRGB)..

**Can be ignored from here**
The thing is... everyday begins with.. Now, I know all about colors.. and ends with ..WTH! I was doing it wrong..
I want to focus more on creating but gets lost under the hood (some part of the problem is my programming background).

gez
Fusioneer
Posts: 109
Joined: Mon Jul 16, 2018 6:21 pm
Location: Argentina
Been thanked: 13 times
Contact:

### Re: Contracting Alpha? (Send Help)

Ayush Bakshi wrote:
Tue Mar 19, 2019 4:25 am
I can't believe that someone spent time...
I told you it was fun, and I'm on vacation.

@Midgardsormr Thanks for that!
I never paid enough attention to those sliders thinking their only purpose was troubleshooting alpha errors, but that trick with alpha gain to zero for a pure addition is gold.
I got used to using channel booleans for pass compositing, but this is certainly more convenient and faster to setup. It also helps to have a clean flow layout. But the latter is probably my TOC for having a tidy B-Pipe with everything ortogonal :-p

Added in 17 minutes 53 seconds:
Ayush Bakshi wrote:
Tue Mar 19, 2019 9:45 am
Another piece of puzzle left for me (for now ) is do we still need to sandwich CC and color altering nodes between gamut nodes?
I mean when I'm working in linear workflow (I rendered this chair in 32 bit exr) I put a gamut node before (output - srgb, add gamma) and one after (input - srgb, remove gamma) the CC node. Am I doing things wrong? I read somewhere that Fusion's CC node expects srgb input. Is it still true (Fusion 9)? And if it is true then do we have some list of tools that expect srgb?
(My viewers remain at LUT - sRGB)..
Having color grading done on linear or non-linear imagery only changes the feedback of the tool. It shouldn't be a problem to grade linear directly, as long as you don't expect the same behavior than grading on non-linear.
Some tools will become certainly harder to manage, like curves (in terms of a display-referred image, you have a 18% of the curves graph to control the most critical segment of your dynamic range and a 82% for controlling the part our eyes are less sensitive to), so in some cases it might help to switch to an encode that makes the distribution of values more comfortable for editing (although tools should help you doing this through a view so you don't have to bend the actual data and leave it as linear reference).
I'm quite new to Fusion and I don't know its internals, but there are certainly some display-referred operations around, I wouldn't be surprised if some of the formulas for luminance and stuff like that were hardcoded with the sRGB coefficients. But Idon't know for sure, more experienced people may help you here.
On a side note, you do need to take care of alpha if you're going to grade passes for 100% correct results, as grading may break alpha association. But as I mentioned before, sometimes good enough is good enough and you can get decent results by grading with masks after everything is composited.

Regarding your "linear workflow" keep in mind that what we usually understand as linear workflow is a partial implementation that only refers to linearizing the transfer curve of non-linear display referred images (as sRGB) and turn them into display-linear.
In that case yes, all you have to do is to "remove gamma" from your display-referred images, and apply the gamma again (as a viewLUT for viewing but also in your output if you're rendering also to display-referred formats).
In that case your artwork is always in the 0,1 range of floats, so the only thing that changes is the transfer curve, from non-linear to linear and back.

However, keep in mind that a true "linear workflow" might be scene-referred. That means that your sources and the material you generate has intensities that go from 0 to virtually infinity. 1 means nothing special in that model, and you have a scene with a wide dynamic range that needs to be viewed through a camera transform that picks a portion of that virtually huge dynamic range and maps it to the display limits.
That needs a more complex approach involving tonemapping, desaturation and other sweeteners, so the trick of the sRGB gamma won't cut it anymore.
It also makes integrating display-referred images (like a jpeg background plate) a bit trickier, as those images don't have the wide dynamic range needed for the scene.

Last edited by gez on Tue Mar 19, 2019 12:25 pm, edited 3 times in total.

Midgardsormr
Fusionista
Posts: 918
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 22 times
Contact:

### Re: Contracting Alpha? (Send Help)

gez wrote:
Tue Mar 19, 2019 10:15 am
that trick with alpha gain to zero for a pure addition is gold.
I got used to using channel booleans for pass compositing, but this is certainly more convenient and faster to setup. It also helps to have a clean flow layout

You'll really like using it with MT_MultiMerge, then! We generally don't do a back-to-beauty composite, but we do use separated Lighting passes. I like to combine those with a MultiMerge, which gives me a sort of virtual lighting board in one node. Instead of having to chase down a half dozen Booleans, each with their own animated Blends, I can have it all in one place.

Ayush Bakshi wrote:
Tue Mar 19, 2019 9:45 am
The thing is... everyday begins with.. Now, I know all about colors.. and ends with ..WTH! I was doing it wrong..

I'm afraid that doesn't stop! Maybe it's not a daily discovery, but I still keep getting schooled on proper color workflow fairly regularly. I still haven't quite wrapped my head around managing the primaries in different spaces (ACES vs Rec709, for instance). Maybe I should take a walk over to Technicolor and see if I can find an engineer who can teach me a thing or three!

Ayush Bakshi wrote:
Tue Mar 19, 2019 9:45 am
I read somewhere that Fusion's CC node expects srgb input. Is it still true (Fusion 9)? And if it is true then do we have some list of tools that expect srgb?

Nothing has changed there. It's really only the Ranges control that's troublesome in linear. The Master sliders all work fine, although Gamma behaves a little differently (but more correctly, really). Separating Shadows, Mids and Highlights is more difficult, for the same reason Gez mentioned re: Curves—the definition of .5 is different, so you wind up really smashing the range down to the left to isolate the shadows. And the control isn't fine enough to make it possible to isolate it perfectly. In that case, I'll often bracket the CC with gamuts. Actually, we have a macro. See attached.

LumaKeyer works better in display gamma. SoftGlow sometimes looks nicer, although that's a matter of taste. Our best lookdev guy does all of his glows and lens effects in sRGB. My eye isn't trained well enough to see much difference, but he insists it looks nicer. Let's see… NeatVideo, if you have that plug-in, works really nicely in log space. I'm not sure what conditions were assumed when it was designed, so maybe that's an accident. ReelSmart Motion Blur likes a tracking image that's gamma 2.2 (sRGB or Rec709, or just a simple gamma adjustment right before). The actual blurred image can have any response curve—it's not luminance-sensitive—only the image it gets its vectors from matter.

FilmGrain, I think, was designed with log images in mind. And that same lookdev artist I just mentioned likes to sharpen in log space. Again, I don't really see the difference… It seems like there may have been a couple of others, but they must not be things I use often.

Oh, and the 3d workspace doesn't respect the viewer LUT override, so if you want to light in proper linear you have to use the Global LUT, accessible through the right-click context menus. Which, as Chad points out, is the proper way to use device LUTs, anyway. But very few of us do so.
You do not have the required permissions to view the files attached to this post.

gez
Fusioneer
Posts: 109
Joined: Mon Jul 16, 2018 6:21 pm
Location: Argentina
Been thanked: 13 times
Contact:

### Re: Contracting Alpha? (Send Help)

Midgardsormr wrote:
Tue Mar 19, 2019 11:59 am
You'll really like using it with MT_MultiMerge, then! We generally don't do a back-to-beauty composite, but we do use separated Lighting passes. I like to combine those with a MultiMerge, which gives me a sort of virtual lighting board in one node. Instead of having to chase down a half dozen Booleans, each with their own animated Blends, I can have it all in one place.
Thanks for the tip. I've told myself several times to try that one and I never did. Now I know I want it.
Midgardsormr wrote:
Tue Mar 19, 2019 11:59 am
I still haven't quite wrapped my head around managing the primaries in different spaces (ACES vs Rec709, for instance).
What do you mean, compositing source from different colouspaces together?
Midgardsormr wrote:
Tue Mar 19, 2019 11:59 am
Maybe I should take a walk over to Technicolor and see if I can find an engineer who can teach me a thing or three!
I'd love to do that and pester the poor guy with stupid questions. If you manage to do it, please ask them where one can get the LUT for pulling scene-referred linear from Cinestyle

Midgardsormr
Fusionista
Posts: 918
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 22 times
Contact:

### Re: Contracting Alpha? (Send Help)

gez wrote:
Tue Mar 19, 2019 12:44 pm
What do you mean, compositing source from different colouspaces together?

That, changing from one to another, the whole OCIO ecosystem. But mostly understanding in a physical and mathematical way what the effect of moving the primaries is, what it should look like, how to identify problems, and what the heck all the terminology means. I'm pretty good with making sure that what I give is the same as what I got, but I'm not so hot at creating a color-accurate working space. It's getting more important as we start seeing proper ACES projects, not to mention HDR starting to show up.