Check if mesh or position is (partially) in shadow

I’m trying to determine if a mesh is (partially) in a shadow cast by a shadow generator.
For example, I’d like to know if a mesh is in a shadow caused by a mountain that blocks the sun from reaching the mesh’s position.

Is there any way to determine this?

You can try to do a raycast. it will be an estimation.
Other solution is to render the scene into a texture. the eye position being the mesh position, and the sun as target.
Then get rendering colors and check if occluded. This might be doable by reading the depth buffer too and checking pixel not at far plane distance.


Thanks for the suggestions, I’ll check them out!