Glow/blur node effect behind another object?

I have a background scene on one render layer with two cubes on a plane. On a second render layer, I have a different colored light (green) shining on the background cube.

As you can see from the image, the composited glow layer is in front of the red cube at one corner. Is there a way to connect the nodes (Z depth?) so that the green glow stays behind the red cube? Can I do it with the existing 2 render layers alone, or would I need a new third layer for the red cube in front?

Thanks for your advice.

Attachments




glowtest2.blend (187 KB)

Well, I got the intended effect putting the red cube on another layer and doing an Alpha Over with the glow effect.

Is there a more efficient way to do this?

Edit: The Alpha Over was darkening the red cube, so I switched to screen added AO and changed the setup a bit.

I would still like to hear any suggestions if there are better ways to glow behind an object.

Attachments


glowtest3.blend (191 KB)




glowtest5.blend (196 KB)