Excitonic mechanism of luminescence excitation of rare-earths and transition metals in solids