The mechanism of color tuning in the rhodopsin family of proteins has been studied by comparing the optical properties of the light-driven proton pump bacteriorhodopsin (bR) and the light detector sensory rhodopsin II (sRII). Despite a high structural similarity, the maximal absorption is blue-shifted from 568 nm in bR to 497 nm in sRII. The molecular mechanism of this shift is still a matter of debate, and its clarification sheds light onto the general mechanisms of color tuning in retinal proteins. The calculations employ a combined quantum mechanical/molecular mechanical (QM/MM) technique, using a DFT-based method for ground state properties and the semiempirical OM2/MRCI method and ab initio SORCI method for excited state calculations. The high efficiency of the methodology has allowed us to study a wide variety of aspects including dynamical effects. The absorption shift as well as various mutation experiments and vibrational properties have been successfully reproduced. Our results indicate that several sources contribute to the spectral shift between bR and sRII. The main factors are the counterion region at the extracellular side of retinal and the amino acid composition of the binding pocket. Our analysis allows a distinction and identification of the different effects in detail and leads to a clear picture of the mechanism of color tuning, which is in good agreement with available experimental data.