4
$\begingroup$

I'm looking for a way to render a mesh that resides inside another mesh, here is an image of what I mean:
enter image description here
I want the part of the monkey that is inside the cube to be rendered, so the result would look like this:
enter image description here
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?

$\endgroup$
4
$\begingroup$

You can achieve this by using render layers: Object ID and Transparent color

  1. Give the cube a transparent material.
  2. 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).
  3. Render, go to the node editor and set up a node tree as in the attached image or blend file.
$\endgroup$
  • $\begingroup$ Could you share a blend file of that? $\endgroup$ – lukasz1985 Sep 3 '15 at 12:56
  • $\begingroup$ Oh, I see the result in the background. That's certainly not what I want. $\endgroup$ – lukasz1985 Sep 3 '15 at 13:22
  • $\begingroup$ Sorry, my bad, didn't see the 2nd image you posted. This is still attainable with render layers, will update my answer in a bit to show how. $\endgroup$ – TLousky Sep 3 '15 at 14:11
  • $\begingroup$ Edited, have a look and see if this works for you. $\endgroup$ – TLousky Sep 3 '15 at 14:24
  • $\begingroup$ Yup, exactly what I wanted, now I'll have to figure out what you did there :). Sorry for posting this comment from a different accout, I'm having some serious problems tracking my SO accounts. I would certainly accept this answer if I could... Nevertheless, really, thanks a lot! :D $\endgroup$ – spectre Sep 3 '15 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.