How to render mesh that's inside another mesh? I'm looking for a way to render a mesh that resides inside another mesh, here is an image of what I mean:



I want the part of the monkey that is inside the cube to be rendered, so the result would look like this:



I know, I could achieve this using boolean operators, but this is prone to error due to not closed meshes, also because I will have cases, where multiple objects will lie inside the boundaries. 

Is there any other way I could achieve this?
You can achieve this by using render layers:



Give the cube a transparent material.
Give each object a different object index for masking with the object ID mask in the node editor (Properties Window --> Object tab --> Relations --> Pass Index).
Render, go to the node editor and set up a node tree as in the attached image or blend file.