How can I make the light bar, after compositing (applying the blur effect on it), be displayed behind the ball, not in front of it?

enter image description here

  • $\begingroup$ First off, recognize the reason why it's doing this - or appearing to. It's because you're using the Add blend mode, and your bar is quite light. That realization will help you find the solution (use alpha over, etc.) $\endgroup$
    – wchargin
    Commented Oct 2, 2013 at 0:37

3 Answers 3


ID Mask:

Expanding on Gunslinger's answer, this can be done on two render layers, using an ID Mask node:

  1. With the foreground object selected, set the Pass index to 1 in Object properties > Relations:

    pass index image

  2. Enable the Object index pass in Render Layers > Passes:

    passes image

  3. Add an ID Mask node and set the Index to 1.

  4. Plug the IndexOB output from the Renderlayer node into the ID Mask node. This will provide a mask for the foreground object:

    mask node

  5. Mix:

    Simple mix setup

    Gunslinger's setup is better as it preserves the sky:

    Gunslinger's mix setup with ID mask


rendered result

Note that you can also use ID masks on a material basis.
Enable Material index in Render layers > Passes, and set the pass index for the material:

Use Materials > Settings > Pass index to set the pass index of the material in Cycles:

cycles material pass index

Or in Blender internal use Materials > Options > Pass index:

BI material pass index


If, you are rendering with Blender Internal, one way to go about this is to go to the render layers with the ball and the bar and under Layer, untick Sky for both. Since this will remove the background from both those layers, just create another RenderLayer that will just be the sky.

enter image description here

Now if you use an Alpha Over node, you can choose which object appears over which one by switching the inputs. You will then use another Alpha Over node to get back the background.

enter image description here

For Cycles, you can get the same results by making sure that Use Environment is ticked under Layer and then ticking Transparent under Film, this will affect all render layers however it seems so perhaps you can use an image as the second input for the second Alhpa Over node, just render out a nice gradient etc and load it back in as an image.

  • $\begingroup$ Thanks. But unticking Sky for them make their backgrounds black not transparent. On the other hand, ticking Transparent under Film make the three layers' backgrounds transparent. $\endgroup$
    – Jikk
    Commented Sep 26, 2013 at 17:21
  • $\begingroup$ Not sure how you're getting that, it should be transparent. Try going to Render > Output and changing it from RGB to RGBA. If that doesn't do anything, please upload and share the blend-file, it is possible you changed something elsewhere. $\endgroup$
    – iKlsR
    Commented Sep 26, 2013 at 17:37
  • $\begingroup$ docs.google.com/file/d/0B64HAX4F6H-YTmlra0otX3VXckE/… $\endgroup$
    – Jikk
    Commented Sep 26, 2013 at 18:06
  • $\begingroup$ @Jikk In the future, please specify what render engine you are using. I very rarely use Cycles so i'm not able to really help in regards to that and it seems that this doesn't work so i'm not sure. This answer only applies to the Internal Renderer. $\endgroup$
    – iKlsR
    Commented Sep 26, 2013 at 18:19
  • 1
    $\begingroup$ @Jikk It would be best if you asked that as a separate question as you are more likely to get better answers that way. I added a simple workaround if using Cycles to the answer, did you try that? Also see, Can I use Cycles materials with Blender Internal?. If the answers seem confusing, please use the comments section to request clarification from the authors. :) $\endgroup$
    – iKlsR
    Commented Sep 28, 2013 at 16:45

Another way to do this would be to render another pass with only the ball, call it mask. Override the material to be pure black.

Multiply the line with this renderpass. Before or after the blur node if you want the glow to overlap the ball slightly, or not.

Note! (if I have time tonite, I will update the screenshot). The background of the mask must of course be white, else it will dim the line.

Node setup here: Node setup

  • 2
    $\begingroup$ Instead of rerendering the ball/cube, why not use a id mask node with a object or material index? $\endgroup$
    – gandalf3
    Commented Sep 26, 2013 at 19:37
  • $\begingroup$ You are right. I just couldn't figure it out. $\endgroup$
    – Gunslinger
    Commented Sep 27, 2013 at 6:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .