Sprite outline based on light position

Hi,

I have simple sprite (for example black box) and I like to add to it outline (red line on example image) but based on light direction.
I currently have outline post process effect on whole scene, but Im not sure how to apply it only on selected objects with outline based on light direction.

Can you please point me how to achieve this effect?
Thank you.