Over time, the layer of cells fold into a cup that allows for sense of direction, a "pinhole" and later a lens and cornea allow light to be focused.
Complex eyes of squids and octopuses and of vertebrates evolved from an ancestral simple cluster of photoreceptor cells.