How to get depthmap from offscreen?

I want analysis sunlight for buildings.
Firstly, i calculate the positon of sun(x,y,z), and create a offscreen camera there.
then i want to get the depthmaps every hour via offscreen camera to find out the shadow area.
In some case, the depthmap will be empty(every pixel’s depth is 0)

What’s the reason for this? How to get depthmap accurately?