How to combine two objects in compositor

Hi! tell me please how to render on different layers two objects where one object is inside another one (eyes on eyes holes). I want to render the head of the character in one layer and the eyes on another layer and after this I whant to combine two render pictures inside Blender compositor.
Here the example of what I whant to get:

I want to achive this mixing those two pictures:

one

two

But when I mix one and two pictures in compositor I get this

So the question is:
How to mix those images and hide the parts of the eye wich not wisible (wich inside the head)?

I use this node mix inside compositor

Well, you will have to render a third time, now both objects together in their final position aka your final image to generate a mask that defines how much of the eyes are gong to be seen.

Dont know if thats the fastest option for that but you could just activate cryptomatte in the render layers and then the cryptomatte node in the compositor will give you the exact mask you need.

For your shown usecase you could also just delete the backside of suzanne so you get transparent eye sockets but thats ofc not really useful all that often

2 Likes

In the layer with the head put the eyes in their own collection and set the collection to “hold out”
(to see the hold out icons click the “funnel” icon and enable them (it is a rectangle with a round hole.)

That layer will give you the head and alpha where the eyes are.

Now you can place that image over the one with the eyes in the compositor.

4 Likes

You could use a Z-Combine node to mix two renderings together like this:

3 Likes

Thanx a lot! this is what I whant

1 Like

Thanx a lot! This is solution too and the second way how it possible to achive this mix… Tank you!

1 Like