You know that the sun's ultraviolet (UV) rays can cause skin cancer and premature aging, and that wearing sunscreen (year-round!) is an important way to protect yourself. But research has shown that sunlight also seems to affect health in a lot of other ways, both positively and negatively.

"One American dies every hour from skin cancer, and the overwhelming majority of these cancers are caused by overexposure to UV light—there's no question about that," said Dr. Darrell Rigel, clinical professor of dermatology at New York University Langone Medical Center. "But that doesn't mean you should stay inside all day or that there aren't plenty of health benefits to being outdoors. You just have to balance everything and use common sense to protect yourself."

Here's what you need to know so you can make smart choices when you step outside.

Mood

Sunlight triggers the release of the feel-good brain chemicals serotonin, so spending time outdoors has been shown to boost mood and relieve stress. And for some people, not getting enough sun during winter months can even trigger a type of depression known as seasonal-affective disorder. (In rare cases, sunlight can trigger depression.)

Luckily, you can fight the effects of SAD, or even a bad mood, without exposing yourself to harmful UV rays, Rigel said.

"You don't need ultraviolet light to feel better, you just need visible light," he said. "Just being in a bright room can help." Special light boxes, which don't give off UV rays, may also help.

RELATED: 12 Worst Habits for Your Mental Health

Vitamin D levels

Sunlight helps the body make vitamin D—an important nutrient for healthy bones, brains, and more. Vitamin D is found naturally in very few food sources, so people need to get it either from sun exposure, supplements, or fortified foods, like milk. (Fatty fish, such as salmon, naturally contain vitamin D.)

You don't need much sunlight to get adequate vitamin D, especially if you have pale skin or red hair; for most people, just 5 to 30 minutes twice a week, with your face, arms, legs, or back exposed without sunscreen is enough. But still, many Americans don't get enough. And because of very real skin-cancer concerns, the American Academy of Dermatology recommends getting your vitamin D from a healthy diet and/or supplements—not from the unprotected sun exposure.

RELATED: The Best Foods for Every Vitamin and Mineral

Heart health

Many studies have suggested that Vitamin D deficiency is linked to cardiovascular disease. And in 2013, scientists in Denmark found that sun exposure—even when it also causes skin cancer—may actually protect the heart: When they analyzed more than 4 million medical records, they discovered that people who'd been diagnosed with skin cancer were less likely to have had a heart attack (or to have died from any cause) over the course of the study.

"As skin cancer is a marker of a substantial sun exposure, these results indirectly suggest that sun exposure might have beneficial effects on health," the study authors wrote.

However, they caution that this does not prove a cause-and-effect relationship, and that sunlight's effects on heart health should be studied more directly.

Strong bones and muscles

In that same Danish study, researchers also found that having a history of skin cancer was linked to a lower risk of hip fractures in people younger than 90. That may be because vitamin D helps the body absorb calcium, which is important for healthy bones.

Vitamin D is also important to muscle health, and people with low levels are more likely to experience muscle cramps and joint pain. Sunscreen blocks the body's ability to make vitamin D, though, so taking supplements or eating fortified foods are still the safest way to get your fill.

RELATED: 14 Surprising Facts About Healthy Bones

Multiple sclerosis

Getting high levels of vitamin D, either from sun exposure or food, may decrease your risk of developing multiple sclerosis (MS). There is strong evidence that people who live at higher latitudes, and therefore get less exposure to UV rays, have a higher risk of the disease than those who live closer to the equator.

A 2014 study also found that correcting vitamin D deficiency may slow the progression of MS and related brain lesions, but the researchers only looked at dietary supplementation—not access to sunlight.

Pancreatic cancer

Rates of pancreatic cancer—the 12th most common cancer in the world and the seventh most deadly—are highest in countries with the least amount of sunlight, found a 2015 study from the University of California San Diego School of Medicine.

"If you're living at a high latitude or in a place with a lot of heavy cloud cover, you can't make vitamin D most of the year, which results in a higher-than-normal risk of getting pancreatic cancer," said lead author Cedric F. Garland, DrPH, in a university press release.

Breast cancer

Sunlight exposure may also be associated with lower risk for another common cancer, according to a 2014 study published in the journal Environmental Health Perspectives. Women who reported spending an hour or more outside every day for the last 10 years were less likely to have had breast cancer than those who reported less time in the sun.

As with other studies, the authors suspect that vitamin D production is responsible for the link—although they weren't able to find proof on a genetic level. The authors were also surprised to find that sunscreen use did not seem to affect cancer risk, but they point out that it could be because SPF is often applied too sparingly or infrequently.

RELATED: 12 Things That Probably Don't Increase Breast Cancer Risk

Blood pressure

Rates of hypertension tend to be higher in the winter and in countries farther from the equator, and a 2014 study published in the Journal of Investigative Dermatology provides a possible explanation: Exposure to sunlight causes nitric oxide in the skin to be absorbed into the bloodstream, which can help widen blood vessels and lower the pressure inside them.

"Our results add to an increasing body of evidence suggesting beneficial effects of sunlight above and beyond those afforded by vitamin D," said study co-author Martin Feelisch, PhD, professor or experimental medicine at the University of Warwick in the U.K. He also adds that spending more time in nature may have psychological effects on stress reduction (which can also help control blood pressure).

Lung health

If you live in an urban area that's dense with cars or factories, the sunshine may be making the air you breathe even dirtier. That's because UV rays can trigger the release of smog-forming chemicals from polluted air and the grime that settles on buildings and outdoor surfaces, according to a study presented at the American Chemical Society's 2015 annual meeting. Air pollution has been linked to asthma and early mortality, and possibly a higher risk of stroke, heart disease, and other health problems.

Aside from moving away, you may not be able to do much about this problem. But you can keep track of ozone levels in your community, and avoid unnecessary outdoor activity on days that are rated unhealthy. Exercising outside in the mornings can also help, since smog gets worse throughout the day as pollution mixes with sunlight.

RELATED: 10 Best Big Cities for People With Asthma

Arthritis

A 2013 study published in the Annals of Rheumatic Diseases found that exposure to ultraviolet B radiation—one of two types of rays (UVA and UVB) found in natural sunlight—may reduce women's risk of rheumatoid arthritis. Study participants who lived in the sunniest areas of the United States (like Hawaii and Arizona) were 21% less likely to have developed the degenerative disease than those that got the least sun (like Alaska and Oregon).

Interestingly, though, the link was only found among older women. This may be because people have become more careful about sun protection in recent years, and the younger participants likely spent more of their lives wearing sunscreen or actively avoiding the sun.

This article originally appeared on Health.com.