Jump to: Board index » General » Fusion

Noob alpha premultiply/divide confusion

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Martin Riley

  • Posts: 12
  • Joined: Fri Jul 28, 2017 9:33 am

Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 8:41 am

Hi,

I have a flame effect rendered in Phoenix fd which is premultiplied.
sourceFile.png
sourceFile.png (289.93 KiB) Viewed 5050 times


When I load it into Fusion it looks how I'd expect. The alpha is pretty solid (over the checkers) and the flames are bright and orange/yellow.
inFusion.png
inFusion.png (98.55 KiB) Viewed 5050 times


But when I export it from Fusion and try to lay it over an image in photoshop, any semi transparent pixels are almost completely transparent, (this includes any glow or other effects from fusion, which almost completely transparent)
fusionOutput.png
fusionOutput.png (175.93 KiB) Viewed 5050 times


Is there any way to get the outputted png file to contain the same sort of alpha information that it appears to have in the Fusion editor?
I've tried every combination of Pre-divide/post-multiply I can find. But nothing seems to do the trick. I thought I'd got it when I added a pre-divide node before the save node, but that just seems to desaturate the flame.
Any help would be very gratefully appreciated.
Offline
User avatar

michael vorberg

  • Posts: 943
  • Joined: Wed Nov 12, 2014 8:47 pm
  • Location: stuttgart, germany

Re: Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 10:40 am

How does your alpha channel look if you watch it before the saver?
Transparency and alpha are 2 different things in Photoshop.
Maybe also try another image format, like tiff
Offline
User avatar

Bryan Ray

  • Posts: 2488
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 3:49 pm

PNG's specification dictates unpremultiplied alpha. Fusion will let you use a premultiplied PNG with no problem, even though it's wrong, but Photoshop will "helpfully" premultiply it again for you.

Section 12.8: https://www.w3.org/TR/PNG-Rationale.html

I am not sure if there is a way to unmultiply an image in Photoshop. There is no Divide option in the Calculation menu.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Martin Riley

  • Posts: 12
  • Joined: Fri Jul 28, 2017 9:33 am

Re: Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 4:19 pm

Thanks for the reply guys.

I think mentioning photoshop was misleading. I was only using that as an example. I'm actually rendering sprites for games. Whatever I view the final png in, photoshop, gimp, the game engine, windows picture viewer, the flame is too transparent.

@Michael Here's the alpha as viewed in fusion. It doesn't matter what file format I output, it always looks the same.
fusion-Alpha.png
fusion-Alpha.png (8.16 KiB) Viewed 5008 times
Offline

Martin Riley

  • Posts: 12
  • Joined: Fri Jul 28, 2017 9:33 am

Re: Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 5:52 pm

I get a similar effect when I try to output semi-transparent effects like glow or highlight from Fusion.

For example, here's a coin to which I've added vector motion blur and a highlight effect. In the Fusion viewport, the highlights are brightly visible.
fusionCoin.png
fusionCoin.png (84.48 KiB) Viewed 5001 times


But as soon as I try to use the outputted image, I can hardly see the output at all and there's a dark fringe like it's premultiplied.

What is the Fusion viewport doing that isn't happening when I render!?!?
Attachments
fusionOutputCoin.png
fusionOutputCoin.png (28.54 KiB) Viewed 5001 times
Offline
User avatar

michael vorberg

  • Posts: 943
  • Joined: Wed Nov 12, 2014 8:47 pm
  • Location: stuttgart, germany

Re: Noob alpha premultiply/divide confusion

PostTue Sep 26, 2017 6:53 pm

as you can see your alpha is very weak in the area of the flames, seems that it will be saved with the wrong/double premultiplication.

the viewport shows the image as it is but when you save it might get premultiplied again. in this case everything without the alpha will be lost (multiply by 0 = 0)
Offline

Martin Riley

  • Posts: 12
  • Joined: Fri Jul 28, 2017 9:33 am

Re: Noob alpha premultiply/divide confusion

PostWed Sep 27, 2017 11:29 am

Bryan Ray wrote:PNG's specification dictates unpremultiplied alpha. Fusion will let you use a premultiplied PNG with no problem, even though it's wrong, but Photoshop will "helpfully" premultiply it again for you.

Section 12.8: https://www.w3.org/TR/PNG-Rationale.html

I am not sure if there is a way to unmultiply an image in Photoshop. There is no Divide option in the Calculation menu.


Thanks Bryan, I think this where I'm likely to find the solution.
Do you know of any way to unpremultipy a premultiplied png image in fusion?
I've tried toggling pre-divide by alpha in the saver.
I've added an AlphaDivide node after the loader
I've toggled Post multiply alpha in the loader.
And various combinations of all of the above.

But, nothing seems to work. When I render out the png the flames are too transparent and/or undersaturated.

:(
Offline

Hendrik Proosa

  • Posts: 3037
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Noob alpha premultiply/divide confusion

PostWed Sep 27, 2017 12:27 pm

What do the RGB channels look after doing alphadivide?

You could test if your saver puts out correct image by a simple setup:
- create a circle shape in random color
- blur it
- do an alphadivide

Result should have identical RGB values everywhere where alpha is not zero. Image is in unpremultiplied state now. If RGB values fall off towards the edge, something is wrong with alphadivide. Now if you write it out to png, does it look as the blurred version in second step when you open it in PS?

But I suspect there is something else going on, most probably you have some stuff in RGB channels while alpha is zero. It is not a problem by itself, actually it is the only way to produce emissive elements when you must use over, not add operation, but these values are lost wheneven the alpha premult operation is applied. If you can't turn off the premultiplication for png files in your game engine, try to use some format which is handled as already premultiplied.

PS. I guess the loss of color is due to very low alpha values and heavy rounding/clipping due to that when doing alphadivide.
I do stuff

Return to Fusion

Who is online

Users browsing this forum: hgergely and 23 guests