I may be wrong about this. But I think the reason why sun shines through the terrain is becuase the terrain mesh issingle sided. IE The terrain is opaque from the normal side. But from the other side its completely ‘transparent’ (though a better term would be ‘non-existant’). The reason for this is, as you probably know is the facing of a triangle is determined from the order in whcih triangle vertices are given. So from the opposite side the rotation is wrong and it will be treated as a back-face (which is expected).
Now probably due to this reason those area covered byt terrain (when viewed from other side) wont write anything to the depth buffer. Ths might probably make the lighting to think taht there is no blocking obecjts between the light-source and thoser other obejcts (trees,etc.).
So I would suggest you to set the terrian material to two-sided and see if that makes any kind of difference to the sun-penetration issue. But even if this does work, it will make the rendering slower. Becuase two sided materials are expensive and will bypass the optimization we get from ignoring back-faces
But this is an assumption and I might be completely wrong about this.