Change color based on shadow-

Hi,

I am trying to get an object to have a different color when in shadow. This should be done dynamically. It works by getting a BP to give me a light vector and in general change the color based on that. But i would like to be able to have the same thing if an object A comes in front of the light and cast a shadow to an object B. The object B then will be a specific color/texture in the part that are not hit by light.

Any idea how to approach this?

Thanks.