Dynamic limits of a ShadowMap

Hello, I post here because I’m not sure how to deal with a problem.
I have a scene where the scenery is made of a large set of thin instances of multiple meshes all of them making and recieving shadows.
The light source is a directional light and it renders well except the whole resolution of the shadow map covers the whole map and I’d like to narrow it to the visible portion (for a finer rendering at equal shadow map resolution) defined by the camera and I couldn’t find a way to define the limits of the shadow map tha would allow me to narrow it down dynamically.
I thought of activating/deactivating the thin instances depending of the position of the cam but that will be quite time consuming and I’m not sure about the performance impact.

Thanks in advance for your help.

Adding @Evgeni_Popov