9
$\begingroup$

I'm trying to render a lightsaber on a transparent background to use as game sprites. I've followed a tutorial on youtube to create the glow/blur effect and it worked great on a black background but it's completely invisible on a transparent background.
I figured I had to put an alpha channel node somewhere to make it work but I tried all the "alpha" named nodes all over the place and without success.

This is how the node setup looks like compositor nodes

Here is the blend file if you want to take a closer look.

EDIT: Found a solution/workaround. Doesn't look as good as before but it's close enough.

compositor nodes

$\endgroup$
  • $\begingroup$ Welcome to the site :) Answers/solutions belong in the answer section below, please avoid putting them in the question. Thanks $\endgroup$ – gandalf3 Jul 15 '15 at 18:58
8
$\begingroup$

There is a fundamental problem with glows. Glow cannot be merged into a composite with alpha, because such layer is then composited using the 'mix/normal' color operation. What you need is having the glow separate and combine it with add/dodge. Here is the explanation:

enter image description here

If the Glow layer (foreground) is lighter than Background, the Normal/Mix color operation with alpha will not be as bright as original Add operation with alpha. If the Background is lighter than the glow (a color glow on white) - the end result will be darker than Background leaving unwanted effect!

That's why you never ever ever composite color glows into a single merged layer with alpha that's supposed to be overlayed with Mix/Normal mode over some other than complete black background.


Now let's say you have object with a color glow on black background and you need to make this background transparent. Here is how you correctly do it:

enter image description here

You break down the image into channels and use each channel as alpha for a solid red green and blue - what this is is separating the background per channel. As it is black the alpha of the background is 0. You then add the colored channels with alpha together to reconstruct the image. Simple.

With nodes when adding the channels together turn Include alpha of second input on:

enter image description here

$\endgroup$
  • 1
    $\begingroup$ @cegaton I learned this trick by reverse-engineering Photoshop color actions a while ago, I believe it was this action: howtogeek.com/59634/… $\endgroup$ – Jaroslav Jerryno Novotny Dec 19 '15 at 19:58
  • 4
    $\begingroup$ This is actually incorrect. Glows are perfectly well expressed using associated alpha. @Gez's answer blender.stackexchange.com/a/44126/213 demonstrates. Remember, alpha formats are not identical, and that fire example is ridiculous simple using a properly generated associated alpha image. Associated alpha images represent both emission and occlusion, something that unassociated alpha images cannot. $\endgroup$ – troy_s Jan 3 '16 at 3:20
  • 1
    $\begingroup$ @jerryno I completely agree that the general concept is a slave to the engine compositing alpha correctly. What I was taking issue with was the “never ever ever” for glows. Associated alpha works exactly as it should in this instance when setting alpha to zero and non zero RGB; it is an add. So indeed, you can composite fire, glows, halations, etc. with a standard alpha over. The issue is that unassociated alpha can never express this very legitimate composite, which is why many consider associated alpha as the one-true-alpha. $\endgroup$ – troy_s Jan 3 '16 at 18:49
  • 2
    $\begingroup$ This setup is both pointless and misleading:The ONLY thing achieved by this is to produce an associated plate with alpha=0 that cheats the broken Blender's viewer (that uses unassociated alpha) into showing the emission. It would be exactly the same to just use a set alpha node and plug black to alpha, without all the channel separation/recombination stuff and plug it to an alpha over node. Also, the exact same effect would achieved by a single add node. It's just the viewer that is broken. Associated alpha should work straight away without all the fuss if the viewer worked properly. $\endgroup$ – Gez Jan 14 at 16:03
  • 1
    $\begingroup$ Sadly it's still broken in 2.8. Same problem. $\endgroup$ – Gez Jan 14 at 16:05
8
$\begingroup$

Alpha compositing with associated (often called "premultiplied") plates allows luminescent transparent pixels to be composited. You just need to make sure that you are saving to a format that allows associated alpha (exr, for instance) and that the program that will do the compositing can interpret that alpha channel correctly (i.e. that it doesn't multiply the alpha channel to the foreground plate as part of the alpha over operation).

This image shows how to produce a simple glow and save it as EXR

This image shows the resulting exr imported back in blender and composited over a gray background, keeping the glow

Check this simple example. There's nothing strange to be done, just add the glow and save as EXR. To check it's working, load the resulting image into the compositor, and do an alpha over on gray. You'll see the glow. Notice that Blender's viewer is a bit broken and won't show the glow when you plug the viewer straight to the RGBA output of the loaded EXR, but the glow is there and will show with the alpha over operation.

Here's the .blend file:

$\endgroup$
  • 1
    $\begingroup$ Yes! This is strange that Blender's viewer isn't doing this right. I had a lot of trouble with compositing fire+smoke renders because of this. $\endgroup$ – unfa Mar 23 at 18:46
-1
$\begingroup$

I had the same problem and found solution. The color nodes just don't handle alpha very well. You just need to go to converter nodes and use the separete and combine RGBA, then combine red with red, green with green, blue-blue and ALPHA with ALPHA ;D (I used the add node for this).

If you want to control the intensity of the glow you need to put a multiply node between the separate and combine RGBA. and to control all the multiply nodes at the same time add a single value node (you find it in add/input/value node.) connected to the second slot of the multipy node.

In my case I used the add node because I needed to put an input outside the node group. I hope it helps. enter image description here

$\endgroup$
  • 2
    $\begingroup$ I don't think this node setup is valid, you are adding the image over itself creating over-exposures. Also the complicated node network is nothing more than just a single Add color node. $\endgroup$ – Jaroslav Jerryno Novotny Dec 19 '15 at 19:21
-2
$\begingroup$

What I would personally do, is to use the Difference Key or Color Key node with the version with a black background. Both nodes provide the transparent color and b&w matte.

$\endgroup$
  • $\begingroup$ Thanks for the reply, I tried the nodes you mentioned but I could figure out how to use them. Sorry for being such a noob. I found a workaround in the meantime and got a decent enough result $\endgroup$ – BogdanM Jul 15 '15 at 14:06
  • $\begingroup$ Whatever works. Glad that you came up with something functional. $\endgroup$ – Mörkö Jul 15 '15 at 15:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.