How to know if an actor is in the shadows

I thought about creating an advanced farming system. One of the problems that got in my way was this: how to find out whether the actor is in the shadows or not - sunlight, spotlight or point light, all included in the calculation. Help me.
P.S.
Sorry for my English.

There isn’t really a built-in way to solve it as rendering is totally detached from the game thread. What some people do is to gather all nearby light sources (plus directional and whatever global light you have), and check which one has a successful line trace to your actor (and you can use the color and the distance to calculate how much light might reach your actor).

As you’d think, it won’t give perfect results, as it can’t work with light bouncing, emissive materials and et cetera - but if you don’t need very precise results, it does actually work.

Yes I know a method with tracing from sources, but it is rather resource-intensive way. Can you tell me about getting the color, if not difficult? Thanks in advance.