A tomographic method is described that makes it possible to follow the propagation of shock waves across the photosphere of long-period variable stars. The method relies on the correlation of the observed spectrum with numerical masks probing layers of different atmospheric depths. The formation depth of spectral lines is derived from synthetic spectra of non-variable red giant stars. When applied to Mira stars around maximum light, the tomographic masks reveal that the deepest photospheric layers are generally characterized by blueshifted absorption lines (attesting to their upward motion), whereas the uppermost layers generally exhibit redshifted absorption lines (indicating their infalling motion). Double absorption lines are found in intermediate layers, where the shock front is located. At later phases, the shock front is seen moving towards upper layers, until it leaves the photosphere.