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?
-
$\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$– wcharginCommented Oct 2, 2013 at 0:37
3 Answers
ID Mask:
Expanding on Gunslinger's answer, this can be done on two render layers, using an ID Mask node:
With the foreground object selected, set the Pass index to
1
in Object properties > Relations:Enable the Object index pass in Render Layers > Passes:
Add an ID Mask node and set the Index to
1
.Plug the IndexOB output from the Renderlayer node into the ID Mask node. This will provide a mask for the foreground object:
Mix:
Gunslinger's setup is better as it preserves the sky:
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:
Or in Blender internal use Materials > Options > 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.
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.
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$– JikkCommented 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$– iKlsRCommented Sep 26, 2013 at 17:37
-
$\begingroup$ docs.google.com/file/d/0B64HAX4F6H-YTmlra0otX3VXckE/… $\endgroup$– JikkCommented 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$– iKlsRCommented 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$– iKlsRCommented 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:
-
2$\begingroup$ Instead of rerendering the ball/cube, why not use a id mask node with a object or material index? $\endgroup$– gandalf3Commented Sep 26, 2013 at 19:37
-
$\begingroup$ You are right. I just couldn't figure it out. $\endgroup$ Commented Sep 27, 2013 at 6:07