I have an idea in my head of an animation where the (soft) shadow of some otherwise invisible object is constantly being cast on a character's face. I created that shadow-casting object and parented it to the character's head bone and unticked the "Camera" option in its Cycles settings. So far so good. This would probably work for most shots.
However, that object's shadow is currently also being cast onto other objects such as a wall behind the character or another character standing in front of them which is not what I envisioned...
To put this in more bland, concrete terms:
Light source(s)
⇩
Object A (shadowcaster)
⇩
Object B (foreground)
⇩
Object C (shadowreceiver)
⇩
Object D (background)
ObjectA's shadow should only be visible on the surface of ObjectC, not ObjectB or ObjectD.
The shadows of ObjectB and ObjectC should be visible on all other objects that are behind them respectively.
I suspect the solution might be more related to render layers/passes and compositing rather than material settings (e.g. Light Path nodes) but so far I haven't been able to make it work either way...
Any hints?