There are probably other ways to take care of this, but here’s one:
- You’ll have to add the trees to the scene with the leaves. Don’t worry – you won’t be rendering them.
- Put the trees on a layer that is active (i.e., that shows in the 3D view)
- In the RenderLayer buttons for your leaf scene, de-activate the tree layer so that it does not render.
- Ctrl-LMB click on that tree layer in the RenderLayer buttons. This will put a black dot in the button.
Render, and use the standard AlphaOver node to composite. Normally, the Alpha of a renderlayer is completely transparent for background (nothing to render) and opaque for regular rendered faces. This setup creates transparency in the Alpha channel for anything that would be occluded by the Ctrl-LMB clicked layers. When you examine your alpha channel that comes with the leaf render, you’ll see that it is correct now. The reason I do this instead of using the Z-combine node is dual: Z-combine can give artifacts if you’re using alpha’ed textures like you seem to be on the leaves, and Z-channels are not anti-aliased, which can lead to blocky compositing. The method stated above uses Alpha, which is anti-aliased.
BTW, this kind of advanced comping technique is just one of the things I show in my new book, clickable in my sig. (wink wink) (plug plug)