Starting off I want to clear it out that it may be a duplicate question, but in fact it is not.
1. Here's my previous question Cycles. Masking shader. How to make objects disappear in plain sight.
2. Here's the one using the compositor Mask out certain objects?
3. This one uses Blender Render Mask single object

Problem description:
I need to be able to mask out (make it completely transparent) certain objects in a 3d scene. An object placed inside another object's volume (masking objects are closed mesh, water tight, manifolds) should be transparent. If only a potion of an object is inside the mask (masking object) then only that portion is transparent (invisible on the render).

The main use of this is for motion graphic designs.
Demonstrations of what is needed: (imitated with booleans)

The masking object has only one shader - transparent.
enter image description here enter image description here

Solutions that don't fit and why:

  1. The question at the first link[1] was by me, and the answer was to use Transparent Depth as a factor.
    The problem with that solution is that it doesn't care whether an object is inside something or not, it just renders transparent everything that comes after the transparent surface (the surface of the masking object) masking shader based on Transparent Depth As you can see, from one side it's fine but when rotate the view so that all our objects are behind the masking one, everything that has that shader setup is transparent.

  2. The answer that is given at the second link[2] uses render layers and as a consequence requires compositing. When you work in 3d and have a production scene with many objects that grow out control, that approach is simply not suitable.

  3. At the third link [3] the solution is provided only for the Blender Render and also uses fixed coordinates for a "faked plane" which is done in nodes, not taking into account any real geometry at all.

My thoughts and commentary:
The masking object has only one shader - transparent.
Maybe there is a way to input the geometry of other meshes through pynodes and somehow use it as a factor in mixing emission and transparency.

  • $\begingroup$ Why are boolean operations not working for you for that purpose? $\endgroup$
    – Bruno
    Apr 3, 2020 at 18:46
  • $\begingroup$ @Bruno 3 things: 1. not all objects can be used with the boolean modifier 2. when you have a production scene with lost of objects it's really difficult to keep track of all the objects, masks and modifiers 3. sometimes there is a need to use not a "shadeless" material and booleans tend to create bad normals from time to time which can halt the whole project $\endgroup$ Apr 3, 2020 at 21:53
  • $\begingroup$ right about boolean. Regarding Transparent depth, have your tried playing around using 1 < depth < 2 instead of just 1 < depth? Shouldn't it make objects reappear if light rays go through multiple transparent layers? $\endgroup$
    – Bruno
    Apr 3, 2020 at 22:58
  • $\begingroup$ @Bruno i think lemon's answer provided just the approach that you're taking about, if i understood you correctly $\endgroup$ Apr 5, 2020 at 16:16

1 Answer 1


Using Cycles, you can achieve this by combining transparent depth of the light path node and backfacing of the geometry node.

We want to be transparent what has a depth modulo 2 equal to 1, as we want to be visible what is behind the transparent object (all are considered manifold).

But back faces have an additional transparency depth because they can be behind its own transparent front face.

So we add the two (backface + transparency depth) and set transparent what is modulo 2 = 1.

Here is an example:

enter image description here

Note that in the provided blend file, if the two transparent cubes overlap (intersect), the blue one will reappear. But the two transparent cubes together are no more manifold when overlapping.

  • $\begingroup$ do you think there's a way to make the masks interact in a manner of a logical OR gate (inclusive OR)? so just overlapping wouldn't cause the masked mesh to reappear. $\endgroup$ Apr 4, 2020 at 21:22
  • $\begingroup$ You mean when the two transparent cubes are intersecting? I don't think it is possible as the shader does not know (and can't know) about the geometry that is masking it. $\endgroup$
    – lemon
    Apr 5, 2020 at 5:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .