You likely have a photo of your loved ones that makes them look like the spawn of Satan. A priceless group shot at a family reunion where everyone’s eyes are red, glowing balls of hellfire. A portrait of an adorable puppy—with neon-green eyes that make it look possessed by a ghoul made of glowsticks.

This is the “red-eye” or “green-eye” effect. You’ve almost certainly heard of or fallen prey to it at one point. You may already know that it’s caused by using a camera’s built-in flash in certain scenarios. But what’s actually happening that makes everyone look so...evil?

Your pupil is like the aperture in a camera, and it regulates the amount of light that hits the retina. The retina is more like the image sensor of a camera, as it contains the rods and cones that act as photoreceptors. The more the pupil is open, the more it floods your retina with light. This is the reason why your eyes are so sensitive whenever you have your pupils dilated; they’re basically overexposing your retina. Normally, your pupil would contract to compensate for ample daylight.

When you use a flash, you’re usually operating in dark conditions. Because of that, your subject’s pupils are pretty wide open when you take a picture. And while your eye’s pupils can contract swiftly, they can’t do it fast enough to react instantly to the quick blast of light from a camera flash.

What that does is send a bright burst of light into the wide-open pupil, which reflects back towards the camera off the retina and is captured by the camera as if the eyeball was a glowing Chinese lamp. That red you’re seeing? It’s not the subject’s soul or an inner demon. But it is blood—blood from the choroid, which supplies oxygenated blood to the retina.

Many of the world’s most awesome animals, such as dogs, cats, walruses, and ring-tailed lemurs, have an extra layer of tissue behind their retina called the tapetum lucidum. Even less-awesome animals, such as raccoons and rats, have a tapetum lucidum. This layer reflects light by design; it pings it back toward the rods and cones of the retina, which aids the superpower of night vision. In dogs and cats, the reflection of light off the tapetum lucidum usually shows up as green in photographs, but the color will vary.

Red-eye is really easy to avoid. It used to be more of a problem in the pre-digital days when you were using a camera other than a Polaroid. Nowadays, you can instantly review your photos and reshoot if anyone looks demonic. The obvious solution is to avoid using a flash, although that might be tricky in dim lighting. If you can, jack up the ISO, use a tripod with a slower shutter speed (and make sure your subjects stay still), tell your subjects not to look directly into the camera, or use a constant source of natural light.

If you must use a flash, try to diffuse it, bounce it, or put it on an entirely different plane as the camera lens so that light isn’t traveling directly into the pupil and reflecting right back into the lens. Most modern cameras also have red-eye prevention modes that fire the flash one or more times before capturing a shot. This allows the pupil to react and contract before it gets blasted with the flash.

Green-eye is slightly trickier to solve, because that reflective layer is built into the animal’s eyeballs. Your best bet is a flash-free shot taken from an angle other than head-on.