Render separate layers with foreground and background in a single layer

Fellow artists,

I’m trying to composite a scene with two render layers; one layer is a torus and the other is an object inside the torus.

Given the camera angle, the torus in effect forms both the background and the foreground, with the mesh object in the middle.

The problem I have is that when I render these layers separately (for compositing purposes), I don’t know how to set the appropriate alpha channels or use the correct nodes to produce the right superposition i.e. having the mesh object overlap the background of the torus yet having the torus overlap the mesh in the foreground.

I hope I’ve explained that scenario sufficiently clearly, and if so, does anyone know how to do this?

Many many thanks,

Screen grab would really help as I can’t imagine quite what your issue is.

Sounds like you need to use the object in a Mask Layer. Note that in the example below I mistakenly thought that the cube needed to be in two layers (one to appear in the render, and one to act as a mask), but it only needs to be on one. In the Render Layer settings for the torus, you need to select the layer that has the other object in the Mask Layer setting.

Steve S

I would probably use the mask layer option on render layers but it’s also possible to use Z combine node.

Thanks very much for your help on this one, worked like a charm :slight_smile: