Yes, so the shadow map is what you need indeed.
It is a rendering of the depth of the meshes from the point of view of the light. It is stored as a linear value between 0 and 1: 0 corresponds to the points closest to the light and 1 to the points furthest away.