Direct sun exposure, tanning beds, hormone imbalances, pregnancy, and certain medications can all affect melasma.