How to deal with masks and shadowcatcher when compositing 3D elements over an image or video? I am trying to add 3-D dog ears to a human being in a real life video clip background.
I have to mask a portion of the persons hair over the 3-D model ears I created. The problem is I also have to add a shadow that is cast from the ears over the mask. It seems like every combination I try in the compositor has bad results.
This is the image of my compositor attempts

This is the result where you can see some of the issues I'm having
I didn't check a Mask option, but seems to me more natural to use an Object as a Mask and Shadow Catcher in once, so shadow follow the shape.

Alpha Over node seems to be working as expected.



Notes:

Image in my 3Dviewport is an Empty object for a reference it doesn't influence a render. For the same effect (and probably easier) you can use image as bacgroud for camera (Camera Properties &gt; Background Images) that can be video as well.
With Object ID pass or Cryptomatte you can separate shadow and adjust if needed.