Phosphors, as the key component of white LED device, have attracted much attention from academia and industry. Here, we study from first principles several (oxy) nitride and oxide phosphors, pristine as well as doped with Ce3+ and Eu2+ ions. We first focus on the different emission color of Ce3+ ion in two chemical-close nitrides: LaSi3N5 and La3Si6N11. The electronic structures of the two undoped hosts are similar, and cannot explain such difference. The 4f-5d neutral excitation of the Ce3+ ions is simulated through a constrained density-functional theory method coupled with a ΔSCF analysis of total energies, yielding absorption energies. The atomic positions in the excited state are relaxed, yielding the emission energies and Stokes shifts. The agreement with the experimental data for the computed quantities is quite reasonable and explains the different color of the emitted light. Also, the luminescent centers in LaSi3N5:Ce and La3Si6N11:Ce are identified. We then apply the above techniques to a dozen of phosphors, including the YAG:Ce, Europium-doped Barium Silicon Oxynitrides, SrLiAl3N4:Eu. In general the absorption and emission energies are within 0.2eV and Stokes shifts within 20% of the experimental data.