How do you render an object with a glow behind another obejct?

Beginning

Recently I foudn the two tutorials below on how to create an teleportation effect. It involves 3 objects. The teleportation object (the object that will disappear) , the glow object (the object that appears at the edge of the object disappearing with a glow effect) and the disintegration object (the object that will make the teleportation object disappear). To understand my problem I would ask you to watch the tutorials below. If you already have then great.

Nion’s Blender Tutorial: Teleportation Effect pt. 1/2 Object Settings
http://www.youtube.com/watch?v=M8wqutKvWvc

Nion’s Blender Tutorial: Teleportation Effect pt. 2/2 Compositing
http://www.youtube.com/watch?v=IHvyB6vUrxY

Problem

In the above videos you can see that the camera angle is always slightly above the teleportation object (cup1) and glow object so it is natural to see the glow object overlap the teleporation object. but i found a flaw in this process. when i completed the tutorial i decided to drop the camera below the glow and teleportation obejcts. I expected to see the teleportation object overlap the glow object since it was in front of the glow object but it did not. the glow object was appearing before the teleportation object. now i am wondering how to make the glow object render behind the teleportation object when the camera is below both objects.

in the version i made, instead of using a cup as my teleportation object I chose a rectangular cube. here are my renders showing the problem i have:

camera looking towards the teleportation obejct and glow object from above. it looks fine:

http://farm4.static.flickr.com/3443/3831530641_3e4581e3b2.jpg

camera looking towards the teleportation obejct and glow object from below. the glow should be covered by the teleportaiton object (rect. cube) since the glow is in back of the cube:

http://farm3.static.flickr.com/2466/3831530791_72b139ec32.jpg

Solution?

So obviously the solution would be to make the glow object render behind the rectangluar cube object. But how? Well I contacted the author of the tutorial and he suggested that I have AIIZ turned on in the glow layer. When I did this I got the glow object to appear behind the rect. cube object but it rendered with many artifacts. Here are examples of how bad it rendered:

from above:

http://farm4.static.flickr.com/3460/3831788087_02f67383d5.jpg

from below:

http://farm4.static.flickr.com/3047/3832536142_35912f8d9f.jpg

from below, glow object in rect. cube:

http://farm3.static.flickr.com/2464/3831741477_8593ed1944.jpg

Of course that was not all he suggested. His other suggestions I honsetly could not grasp based on my limited understanding of how nodes work. This is what he said to me after I pointed the problem how to him.

he wrote:

You’re right about that issue. I haven’t thought about that before, but I think I have a solution. Place the cube for the glow above the ‘disintegration edge’ (instead of under it). And then turn on AllZ in the renderlayer settings for your glow. And in the composite nodes you would have to subtract that pass index thing directly on your blurred image before you add it and not after. By the way: instead of inverting the color and then use subtract, you could also just use multiply.

then i wrote:

when I pressed the AIIZ button in the glow render layer and rendered a picture, the glow got poly garbled but was rendered behind the gray rectangular cube. here are the renders of this issue:

http://www.flickr.com/photos/caeious/3832536142/
http://www.flickr.com/photos/caeious/3831741341/
http://www.flickr.com/photos/caeious/3831741477/

i have the pass index of the teleportation object (rectangular cube) set at 1. i do not know what you mean when you say “pass index thing” when refering to the node editor. do you mean the ID mask node? here is a pic of my current node editor set up:

http://www.flickr.com/photos/caeious/3831768521/sizes/l/

sorry, it seems like turning on AIIZ helped a bit. can you describe the actions I should take in the node editor a bit clearer?

then he wrote:

“do you mean to place the glow cube inside the disintegration object completely instead of having it be slightly outside of it?”

exactly. What AllZ does is to mask out stuff, which is behind objects from other layers. That solves the issue on the one hand, but on the other hand your glow object needs to be outside the disappearing object, because you don’t want it to be completely masked out. Or not really completely… you get these strange artifacts again, because there is no distance between the faces (that’s what you see on your screenshots).

“i do not know what you mean when you say “pass index thing” when refering to the node editor. do you mean the ID mask node?”

yep. Your glow object doesn’t cover your disappearing object anymore, and when you subtract the ID mask, you don’t only subtract parts of your the glow, but also parts from the glow object. So what you have to do is to subtract this mask directly from that blur 60 node, before adding it.

I haven’t tried this whole thing on my own, but it should work.

then i wrote:

Ok I have placed the glow object inside the disintegration object and then when I rendered I saw no glow at all. I figure this is normal as I did not complete the node editor step yet. Oh also I do not know what you mean about there being no distance between the faces. What object faces are you speaking of?

ok. i am a bit slow with this node editor but what I understand so far is that I have to do is move the “Subtract” node. Do I move it in between the “blur 60” node and the “Add” node in the “Glow render layer” node line? If so, where do I place the Glow node line’s “add” node image output link? And where do I place the Main node line’s “Blur 4” node image output link? I ask this because as you know these two image outputs where placed into the “Subtract” node. If I am totally off then I am sorry.

after that he never responded. i dont blame him. its complicated and hes probably busy.

My .blend file

Below you can download my .blend file so you can see what I mean exactly.

http://www.pasteall.org/blend/534

i need to get this effect implemented. does any one know how i can achieve the desired results?

The problem is that the glow object and the disappearing object are in the exact position. Blender can’t really render two meshes in the exact position. You can see in the viewport all the hashed lines where it tries to display both at the same time. So, if you tried to mask it with allz, it can’t really mask anything, since the objects are in the same position. A simple way to fix this is to have another object behind your glow object to act as a mask. When your camera moves behind the disappearing object, the glow will be masked out by the object in front of it, but when the camera is in front no masking will occur. Its fairly simple. Just add a plane in a new render layer and give it a shadeless white material. Then you can multiply it (a simple way to mask grayscale stuff in the node editor) against the glow layer. I don’t know what you were doing with the subtract node and the idmask. You don’t really need those.

I included an edited version of your blend file in the attachments.

Attachments

glow_new.blend (174 KB)

don’t know what you were doing with the subtract node and the idmask. You don’t really need those.

It was there so that the ‘bigger’ glow is only visible on the object.

Oh, okay. You might want to put that back in then.