Masking(?) / Hide object behind another one


I have a question which I think could be categorized as a “masking” question, but I’m not sure, I’m so new.

I’m working on this “2-1/2D”-Animation, the camera is not moving. What I want to do can most easily explained by refering to this really simple example: Imagine a picture frame in the scene (most distant from camera), the object portrayed in the picture (simple sphere, closer to camera than frame) should appear moving out of the picture frame and be gone/invisible. How do I go about this? Do I have to look into the msking manual? What would get me started?

What I tried so far is to create an invisible object ( on the edge of my picture frame (and closest to the camera) so that the sphere is hidden behind that invisible object as soon as it exits the border of the picture frame. Method described here:
But then the invisible objects masks out ALL objects that are positioned behind it, including the part of the picture frame that it covers up (and background objects i didn’t mention yet) which is not what I want.
I tried moving the “masking” object and the sphere to a seperate layer but that didn’t help…

I am deeply out of ideas, blender is just so complex… Thanks a lot really for any thoughts on how to go about this!

Kind regards,

Rather than having to try and decipher what you are talking about how about showing clearly what you mean, what you currently have achieved and what isn’t working as you want. Please supply annotated images/screenshots and a blend file of what you have achieved so far.

Thanks for pointing out that my description was unclear.
I made a blend file that should illustrate the issue more clearly, it’s attached.
The objects are named to fit my first description.

  • the green rectangle is the picture frame, the inner part beeing the actual photo, the outer part beeing the frame

  • the purple ball is the content of the photo and it’s moving (think of the photography technology in harry potter) I animated the change of location

  • when the sphere leaves the inner green area, it should disappear

  • the invisible “mask”-object should hide the sphere, but not the outer part of the frame (as it does in my file) nor the background (more background objects on layer 2 of the attached file

  • NOTE: the hiding effect of the “mask”-object is only working in rendered viewport shading.

I hope my question is more clear now. I am aware that using such a “mask”-object is probably a clumsy approach, I just can’t come up with how to do it properly.

Thanks a lot for any ideas!

picture_frame_mask_object.blend (546 KB)

hi everyone,
is my question still explained in a way that nobody gets what I mean? Am I so bad at explaining? (Or at english…)

On my research I must have set a new GS/M (google searches / minute) record and still I’m unable to achive what I need.
I will post my current status, so maybe someone sees what I could do to make it work:

I am now using the Box Mask node to set the “Fac” value of the Mix node which mixes together my background layer with the object layer (meaning the object that’s supposed to disappear from the scene once it moves across a certain boundary).
The result is very close to the required behaviour, however, the grey background of the foremost layer still needs to be hidden. Shouldn’t it be possible to do this with the layer’s alpha value?

Thank you so much for any help!