Occluding material in cycles - Math operations?

Hello. I am looking for a way to occlude one cycle´s material against another like when we setup the render passes from the passes property for the scene in a “holdout” mode.

Think 2 spheres over a plane. One sphere overlaps the second one. You can “see through” the overlapped area and see the plane, but If I check “holdout” for one of the spheres, it also cuts out the plane. I only need the ray to intersect (exclude from rays) the intercepting object.

How can I accomplish this? - Thanks.

3 render layers.

Layer 1 has the scene in it.

Both spheres have object index 1

Layer 2 has just sphere 1, samples set to 1, object index enabled

Layer 3 has just sphere 2, samples set to 1, object index enabled

In compositing:

Layer 2 object index and layer 3 object index go into maths node type “minimum”.

Output of this is the overlap.

Use maths node to subtract the overlap from layer 1 alpha.

From this maths node use set alpha to set alpha of layer 1.

1 Like