Interplay of spin-allowed and spin-forbidden 5d–4f luminescence from rare earth ions