Coding Question, Can you detect shadows

I’m trying to build a game that revolves around stealth. To do so I would like to know if is possible to use ray-casts to detect shadows. If so can someone show me a example?

Thank you for answering!

Shadows are cast on a surface because light from a light source is blocked by some opaque object.

So you can tell whether any given point is in shadow by firing a raycast from that point towards the light, and checking what the first object it hits is. If the raycast hits the light, it’s not in shadow. If it hits anything else along the way, it’s in shadow.