compositing blur/glow with a transparent background

Hi,

When using the node-editor to add a glow/blur effect to my render I only can see it when using a black background but I need a transparent background.When rendering a png with RGBA I get a transparent background but also I lose my glow. What should i do?

Any help appreciated, Twan

How are you mixing the two sources (i.e. what node do you use)?
In principle, I don’t think transparency has anything to do with the glow. I don’t really know your specific situation/node setup so it’s hard to say but in general I’d use a mix node set to add to, well, add the glow on top of the other stuff.
Also note that the glare node does have a mix field whose value ranges from -1 to 1, with 0 denoting a 50/50 influence. So, depending on your inputs, it might be directly usable.

Glow always tends to be subtle, it appears strong on Black because of the extreme contrast. Change the background to a mid grey and you will see what I mean. Many people have to stack the glow on top of itself. Or you may have to alter the alpha channel of the glow to enhance its density (prone to noise though).

I have this setup. One is with a black RGB selected and the other one is with the RGB+alpha selected. In the second one I dont see any glow. And when I use it in my editing program and put a black background in the back I dont see a glow either…

Attachments



Yeah I had this once, you need to add the glow to the alpha pass as well before output :slight_smile:

@Casio23 Thanks for your comment. But what do i have to change to get it working?

http://www.pasteall.org/pic/show.php?id=34699

Try reconstructing the above node setup ^^

You need to add the blur to the alpha pass

@Casio23: TRhanks man, it works! However it only works with the Glare node. I cannot get enough effect to get it working with a blur node. Do you know why it is so difficult to get this effect on a transparent background?

What did you try with the blur node? It should be exactly the same.

Yeah, as far as I know, glare is calculated for each colour, [RBG], but alpha is not a representation of how bright something is, so if you applied a glare to the alpha pass it just wouldn’t work. Normally you just need to add your blur / glare to the alpha pass, however this doesn’t work in every scenario, and I think this is why it isn’t part of the glare node.

Try boosting the glare / blur on the alpha:


And for bonus points you can stick them all in a node group [Ctrl+G] to clean up you nodes :slight_smile:


PRO TIP - clean up the inputs!


Hi Casio23

I’m trying to use your solution. And my result is a black halo around the normal white halo of the alpha background image.

As you can see:

Do you know the reason? this is driving me crazy.

Thank you.

It’s a premultiplied alpha issue…all related to the the fact that internally blender counts on/uses premul but for rgba png output, it’s sometimes preferable to have straight alpha output.
try this:
instead of ramping up the alpha channel with the curves node, try adding an alpha convert node ( premul to key) just before your composite node and make sure that straight alpha is selected in the shading tab. You may or may not have to also select the color unpremultiply box as well…I’m not quite sure how that works.

note that in blender it will not show properly unless you are viewing it with the color +alpha icon selected


it seems to work!!

ok, a need to do more test but this gives me a chance.

thanks a lot

Watch out also for this: the alpha-channel information needs to specify where the glowing region is; not how solid it is. That is to say, you need to be able to adjust the “intensity” (that is to say, the solidity…) of the alpha information, separately from the intensity of the glow from which it is produced. A curves-node can be used for this.

If your “faint glow” also has a “faint alpha,” the two effects combine such that the result is effectively too faint to be seen.

To illustrate, let’s do the math, making up numbers as we go. If the intensity is, say, 0.25, and the alpha is “therefore, also” 0.25, then “0.25 squared = 0.0625.” You’re not going to see anything. You need to be able to say, “if the value of this pixel is, say, 0.10 or higher, the corresponding Alpha should be, say, equal to 0.75.” And you need to be able to “eyeball” both of these adjustments (the glow, and the alpha) independently, by fiddling with mapping curves.

Yeah sorry, boosting the alpha was a bit of a cheap work around, and I forgot completely about pre-multiplied alpha (premul alpha is almost more trouble than it’s worth! - the first step to solving any alpha problems shouldn’t have to be try converting the alpha). Thanks for pointing that out :slight_smile:

ah yes, once again I have misspoken (note my sig)…

you are right, I should have said to fix the premultiply issue and then use the curve node to make it look correct for the target background

Could someone somehow supply a complete node setup? I am just having small difficulty following sundialsvc4’s wise advice…

I’m having the same issue here. I’m trying to output a glow/blur object (not pure white like in the examples above), but it’s not working. I add the glow (run through a “RGB to BW” node) to the alpha then add that result to the blur (also run through a “RGB to BW” node). Nothing. I see from the last couple of posts that there are more steps involved, but I don’t understand what they’re talking about. Can anyone shed some light on this topic?

Node setup is much less important here than understanding of what’s going on and why.
All the problems come from not proper setting of alpha mode in shading options of render, plus interaction between the colors (RGB) and alpha channel.

In order to make the setup work perfectly we have to first take care about setting the proper alpha mode (render settings, shading panel). We have 3 options:

  1. “Straight” (in latest releases it’s called “Transparent”)
  2. “Premultiplied” (In latest releases this option is gone)
  3. “Sky”

By default it’s set to “Sky” which is a big NO NO. If you want to do ANY compositing - change it immediately to “Straight” (“Transparent” in latest releases).
At first it may seem that “Premultiplied” is a good option, but it’s not. I won’t elaborate on this, especially that as we can see this option will most probably be NOT available in new versions, so let’s simply forget about it and begin to be happy that we won’t have to wonder why we should or shouldn’t use it. It’s gone and it’s good.

So this is what we are playing with:


The foreground is our cube. Top left part of the above image shows it composited over transparency grid.
Top left - straight colors of our render. There is nothing in our scene except this cube, alpha mode is set to “straight” so every pixel that’s alpha is ZERO is pure black. Every pixel that’s alpha is greater that ZERO (it may be even as low as 0.000001 or so) will have the color of the cube.
When we disable transparency and look closer on the edges we will see that they are jagged, but it’s not a problem at the moment. It will be taken care of when we composite it over our background using the alpha channel.

When we blur such image we will get some of this black color at the edges. When we think about it without analyzing alpha it’s logical. All of the colors are blurred, so those black pixels from the surroundings of our cube will also be taken into account. This is where this black fringe comes from.

Two component get blurred: Colors and Alpha. Colors however get “mixed” with black pixels. The ones that alpha is ZERO. After blurring we get the result as we we had colors pre-multiplied with alpha. Therefore in order for those colors to mix nicely with the background we have to “reverse” pre-multiplication, which in practice means - we have to divide colors by alpha.
There are several ways of ding it: We can simply use mix node where we plug blurred image into upper socket, alpha into lower one, set blend type to “DIVIDE” and we’re done.
We could as well use another option which is “converting” the alpha mode, so we use “Alpha Convert” node from “Convertor” section. When we set it to “Premultiplied to Straight” we get exactly what we want, meaning: “un-premultiply” or in other words - divide by alpha.

When we do so - we can now use simple “Mix” node with “Use Alpha of second input” option turned on, or use “Alpha Over” node.
The latter is in our case simpler, as “Alpha Over” node expects premultiplied inputs. So if we decide to use “Alpha Over” node - we don’t have to… we even mustn’t convert alpha mode. We plug our blurred cube straight into this node.
When we take a closer look at “Alpha Over” node we see that we have the option there: “Convert Premultiplied”. We need to enable it when the inputs are NOT premultiplied before they go into this node. In our case we DON’T do it, because our sources ARE pre-multiplied.

Below you’ll see 3 setups:

  1. Cube with glare composited over red BG using “Alpha Over” node
  2. Cube with blur composited over red BG using “Alpha Over” node
  3. Cube with blur composited over red BG using “Mix” node

Please note that I didn’t at all use the option with “Mix” node to composite glare. This doesn’t want to work if we don’t use some complicated setups. It IS possible to set it up, but I think it’s rather not practical, especially that we can use just “Alpha Over” node and it will work nicely.


And here are closeups to settings of “Mix”, “Alpha Over” and “Alpha Convert” nodes:


Have you tried taking the alpha output into a mix node top input and factor input with the bottom input as white color image. Then output the mix node into a fast gaussian blur node process, then into the glare node process, then do a screen mix mode. Let the blurred alpha glow mix node output to another mix node as the background and screen mix that with the main color image. This way you might be able to avoid the alpha convert process.