Sun exposure stimulates melanocytes to produce melanin as protection against UV radiation. Prolonged sun exposure can darken the skin, while limited exposure can result in lighter tones.