The pineal gland ? located in the vertebrate brain endocrine gland ? has a number of common features of the retina of the eye. Both organs have developed as pouches diencephalon , act as photoreceptive and produce melatonin in a light-dependent manner . In contrast to the retina , pineal gland has undergone significant evolutionary changes and forming it pinealocytes differ in vertebrates both construction and function .