We already know that the eyes of these organisms are not homologous structures. But now we also know that the genes controlling eye development are homologous. How is that possible? It’s a bit like taking several similar on/off switches and using one to turn on the bathroom light, one to turn on the garbage disposal, and one to raise and lower the garage door — the same switch can be co-opted for slightly different jobs, all requiring a switch. In the case of eye evolution, it probably happened something like this:
More than 500 million years ago, the ancestor of most modern animals evolved the “switch” — the ancestral version of modern Pax6 and its cousins. In that organism, the gene may have helped build the simplest type of eye (one photoreceptor cell and one pigment cell) or helped build a light sensitive protein.
That ancestor then passed the basic gene to all of its descendants.
Some of its descendants began living in an environment in which more sensitive light perception was advantageous. In those organisms, natural selection favored any individuals that happened to use the gene to build more complex and sensitive eyes. Over time, these organisms evolved one type of complex eye — perhaps one like the fly’s compound eye — which was switched on by a descendant of the original gene. Meanwhile, other animals living in a different environment also found fine-tuned light perception to be advantageous. Over time, these organisms evolved their own type of complex eye — perhaps one like the mouse’s eye — which was also switched on by a different descendant of the original gene.
In that way, different lineages (like the mouse and the fly) evolved analogous complex eyes all controlled by the same homologous eye-building gene.