Thursday, September 14, 2017

API Showdown: Vulkan vs OpenGL - A Doomed Comparison


Image result
VS
Image result for OpenGL


You may have heard of Vulkan, not the smarty-pants Star Trek race, but the new-fangled, low-level graphics API. Vulkan has received a lot of hype both for its hopeful efficiency gains as well as its open-source nature, getting out from under the proprietary thumb of Microsoft while still offering cross-platform compatibility.

Efficiency gains? Open-source? Cross-platform? This all sounds well and good, but as with many new technologies, how much of this theoretical horn tooting trickles down to practice? Is the end result really that impressive compared to the tried and true APIs du jour: OpenGL and DirectX? Heck is Vulkan even better at all?


Doomed Comparison

Looking for an answer, I booted up Doom, one of last year's best shooters.  Besides being a critically-and-consumer acclaimed game, it's also one of the first to offer support for both Vulkan and OpenGL, making for a fitting comparison. 

After spending some time in the game and conducting several experiments, the results were simply too meaty not to share.

It all started at the very beginning of the Argent Tower level. I was playing under the default OpenGL renderer when the game started stuttering like a puttering car engine. I checked my stats. The frame rate was definitely dropping.  

Despite multiple reboots, the poor performance persisted and seemed to be tied to a particular overlook (which you will see in the screenshots below).  Whenever I looked out at this area, the frame rate tanked.

This in and of itself isn't too curious. Vast overlooks are infamous for tanking frame rates. What was curious was the CPU and GPU utilization. According to MSI Afterburner, despite my frame rate being relatively low, my CPU and GPU utilization were equally low.

It's one thing for the frame rate to be low and the GPU or CPU cranking at near 100% utilization. That simply means the game is demanding and the CPU and GPU just aren't up to snuff. It's entirely another for the frame rate to be low and the CPU and GPU just twiddling their thumbs at 50% utilization. That just means the game is poorly optimized, the program simply written in a way where the CPU or GPU can't work at their full potential. At this point, it's lack of software optimization, rather than hardware performance holding back the game. This certainly seemed to be the case in this particular scene under OpenGL.


Switching Gears

Given the software-limited nature of the performance dips, I decided to try switching the rendering API. OpenGL was bogging down. What could Vulkan do for me?

In short, a lot. I switched to Vulkan, and it was like night and day. In this particular scene, my frame rates jumped as if they had been given a steroid injection. We're talking from 70fps to 110fps. Not only did my frame rates go up, even better, under Vulkan my CPU and GPU utilization also enjoyed a healthy increase.  These were all great vitals indicating the power hungry program was able to better hook up with the powerful hardware. Given an APIs very purpose is to serve as a link between hardware and software, these kind of metrics are exactly what you would hope for from a good API: High utilization. High frame rate.


Proof In The Pudding

But enough talk. Don't take my word for it. Go see for yourself in the attached screenshots. Take careful note of the MSI Afterburner readouts in the top left of the screen. Most importantly, notice the GPU, CPU, and RENDER stats. I have provided a little key to better parse through the MSI Afterburner readout.

GPU: TEMP, % USAGE, CORE CLOCK
MEM: (Not important here)
RENDER: FPS
CPU: TEMP, % USAGE
RAM: (Not important here)

Note:  All settings Ultra, Resolution 1920x1080x144hz, G-Sync Enabled, Intel Core i5-2400 @3.6Ghz, Nvidia Geforce 970 4GB, 8GB System Ram, Windows 10 64 bit



Scene 1 - Argent Tower (Level Start)


 OpenGL


Vulkan

 


Scene 2 - Argent Tower (Overlook)


OpenGL


Vulkan




Or More Concisely


Scene 1
APIFPSGPU UtilizationCPU Utilization
OpenGL9180%64%
Vulkan10998%75%
% Difference19.78%22.50%17.19%



Scene 2
APIFPSGPU UtilizationCPU Utilization
OpenGL7167%62%
Vulkan10992%92%
% Difference53.52%37.31%48.39%

What it comes to is this:  In each scene, compared to OpenGL, Vulkan shows better frame rate, better CPU utilization, and better GPU utilization. Essentially, Vulkan is able to take significantly better advantage of the hardware. This kind of efficiency is laudable in and of itself. But it's even more impressive when you realize it's not just a bunch of numbers or efficiency for efficiency's sake. It's the power to better utilize existing resources.  It's the power to take the player from lowly lag fest to butter smooth frag fest.  If this example is anything to go by, Vulkan has the potential to pack a game-changing punch.


Tuesday, September 12, 2017

The Storm

It all started late last night.  The rain was pelting.  The wind was howling.  The weather was stewing with all the pent up ferocity of an atmospheric temper tantrum.

I lay in my bed, the covers tightly tucked under my chin.  Even from my cozy cocoon, the presence of the storm was powerfully intimate. I could almost feel the tempest pressing up against the window beside me.  The warmth of my covers felt heightened, juxtaposed against the shower soaked window.  I cracked the window slightly to better hear the rain. The poignant pitter-patter was strangely serene.

I lay my head back into the comfy confines of my pillow, listening to the rain-drop parade.  The winds and rain swelled together in alternating crescendo.  First a measure of relative calm.  Next a bar of vehement volume.  Then, right as the crescendo would approach near-uncomfortable levels, the storm would once again gradually subside.

The pattern of alternating crescendos continued, a torrential tide ebbing and flowing with rhythmic cadence, back and forth amidst the black backdrop of night.

I pulled the covers tighter.  Once again the winds and rains swelled with symphonic crescendo.  This time the crescendo sustained, a line of drummers striking with unrestrained vigor, struggling to maintain their loudest.  The tension mounted.  It felt as if something were about to burst.  Something had to give.  Then, it did.

The crescendo ended in emphatic crash, a pair of cymbals clanging together in the air.  A guttural rumble ripped through the house, traveling through the foundation and spreading up the walls, a thunderous sound felt as much as heard.  

Reflexively, I sat straight up in my bed, eyes and ears open.  My heart pounded.  My mind raced.  What was that?  Thunder?  Rare for Alaska.  An earthquake?  More common, but this seemed different.

I got out of my bed.  My feet hit the cold floor.  Slowly, one by one, lights came on in the pitch black house as the family congregated in the living room, curious.

We made our way toward the wrap-around-deck, the sound of the sliding glass door opening barely audible over the roar of wind and rain.  The deck lights sparsely illuminated the sheets of rain like an under-powered flashlight, barely piercing into the night.  There amidst the wind-tossed rain lay the tangled outline of a silhouette.

We ventured out further, arms hugged across chests for warmth.  There in a twisted mass of splintered wood and corrugated roofing lay the trunk of a tree, nearly completely horizontal.  The wet leaves and branches sprawled out across the deck haphazardly like a rag doll corpse.  The wind-whipped rain rolled down our faces and tugged at our hair as we pushed forward to examine the damage.

Soon it became clear.  Eyeing the length of the tree, we followed the trunk back.  Off in the distance, the base of the tree and roots were unscathed, still resiliently planted in the ground.  The tree hadn't simply fallen.  It had been snapped in half, violently cracked in two like a twig.  The top half of the tree had then careened into the deck, snapping the railing, downing the awning, and taking various chairs and deck ornaments with it, all in one thunderous, house-rumbling fall.

Coming back inside, we could still feel the weight of the wind pressing into the walls of the house.  We looked at each other and smiled nervously, but affectionately.  There's nothing quite like the shared midnight crisis of a storm to spark the bonds of family or renew your awe of nature.  Hugging, we went back to our beds thankful the tree was on the deck and not in the house.







Thursday, April 20, 2017

Out With The New In With The Old: This Ancient Wisdom Is Lit!


Love and Hate

I have a love-hate relationship with technology.  On the one hand, I love technology.  Case-in-point:  My enthusiasm/addiction for building, tweaking, and troubleshooting computers.

Early on (middle-school-era Mark), this curious tinkering had some unfortunate and smelly side-effects, namely, the fireworks-like frying of a few components (fried components give off a very unique smell somewhat reminiscent of burnt French fries).  But, more important than the forfeited components were the lessons I learned along the way, lessons like never to put a power supply directly on a metal case, or alternatively that metal is not a semi-conductor, but rather an all-the-time conductor.  Truthfully, the inaugural part-fry is an important stepping stone for any would-be computer enthusiast.  After all, learning what not to do can be just as important as learning what to do.


Eventually, this budding passion matured into a capable knack for spec-ing and building custom computers.  Like a chef carefully tasting each ingredient as he develops a recipe, there’s something strangely satisfying about thoughtfully selecting each component to hit that sweet spot of price-and-performance, putting it together, and then finally watching it all roar to life with the press of a power button.  So, I love technology.


I also hate technology.  I bemoan the way cell-phones connect us to those far away, and yet disconnect us from those closest to us.  Similarly, social media connects us to the world at large while isolating us from the world around.  We scroll through our news feeds insulated from genuine human contact.  The concrete jungles we have erected separate us from the planet upon which we live and breathe, disconnecting us psychologically as much as a physically from the Earth.


So, I love technology, but I am also wary of viewing it as a panacea-like savior.  Don’t get me wrong.  There are some amazing high-tech solutions out there, but our 21st century way of life can create the tempting illusion that the best solution is always the most high-tech.  Truthfully, some of the most elegant and effective solutions can be deceptively simple, sometimes even ancient.



Wisdom of The Ancients

Just the other-day, I stumbled upon a fascinating piece of ancient heating technology.  That this ancient technology can rival, and in some cases even surpass, modern offerings makes it as impressive as it is intriguing.  There are as many names for this technology as there are cultures that used it.  It is perhaps most commonly known as a “glazed tile oven” or “masonry stove.”

If you live in the United States, you’d be forgiven for not hearing about this ancient and amazing technology sooner.  While extremely common place in Europe, they were virtually unseen in America until the late 1990s.  The reason for this is surprisingly simple.


For much of history, wood-burning was the primary source of heat.  In Europe, firewood became a relative scarcity.  This created the incentive for more efficient wood-burning appliances to heat buildings.  In America, on the other hand, firewood was so overabundant there was relatively little incentive to move past the inefficient fireplace.  Thus, while America continued to use inefficient fireplaces, Europe and Asia were pioneering a radically efficient heating technology: the masonry stove.



A traditional take on the masonry stove (image courtesy of niftyhomstead.com)

Get this:  The masonry stove can be 80-90 percent efficient.  That means 80-90 percent of the heat generated is outputted entirely into the home.  Compare this to 10-15 percent efficiency of a traditional fireplace where most of the heat is swept up the chimney.  But this is just the beginning. No seriously, hold on to your socks.


The truly revolutionary aspect of the masonry stove is that it heats up people instead of spaces.  This may seem borderline blasphemous, but contrary to the forced-air heating systems in most of our homes, it is possible to heat up a person directly rather than heating the entire volume of air around them.  



Heated Discussion

Most conventional heating systems work like this.  You turn up the thermostat and a furnace heats up air which is then forced into a space until the entire volume of air in that space is at a desirable temperature.  This seems like a good idea on the surface, but there are many issues with heating air.  For instance, convection:  the fact that once heated, air rises to the top of a space even though people are typically at the bottom of a space, the end result being the heat is not where the people are.  Not very good.  Not very efficient.


Convection heating left versus radiant heating right (image courtesy of Dario Camuffo)


Convectional forced-air heating also has the byproduct of creating a less than desirable indoor air climate.  The circulating air caused by convection routinely stirs up and scorches dust, drying out the air.  This can be offset by using humidifiers, but these can create perfect breading grounds for dust mites, molds, and other allergens.  The end result is that force-air systems create a less healthy indoor climate.

But what if you could avoid these problems and instead of heating the entire volume of air in a space, you could just get right down to heating the person and the objects in that space instead?  Well, I’m here to tell you, you can!  This is exactly what masonry stove does through a magical form of energy transfer known as “radiant” heat.

A Personal Sun

The concept of “radiant” heat can see a little foreign at first, but radiant heat is something we are actually all very familiar with on an intimate basis…well, if you get out in the sun that is.

A great way to think of radiant heat is when you are outside on a sunny day next to a spot of shade.  The air in the shade and the air out of the shade is essentially the same air and essentially the same air temperature; yet, when you step into the shade you feel cool, and when you step into the sun you feel warm.  It’s not the air temperature that has caused you to feel warm and comfortable.  It’s the radiant heat of the sun.

The masonry stove works similarly to the sun.  It emits heat in the form of infrared waves.  These infrared waves travel through the air, and more than heating the air itself, the radiant heat warms the people and objects (anything with substantial mass) that it comes into contact with.  This means people can still feel warm without heating every single cubic foot of air in a space.  Essentially, heating with a masonry stove is like having a personal sun in your home.

So what exactly is a masonry stove, and how on earth does it accomplish this magical form of highly efficient radiation?  A great question!  Let me ‘splain.

Modern masonry stove in a lab, covered in heat sensors (image courtesy of cornishmasonrystoves.com)


Rock-et Science

While the above science of radiation may seem a little high-level, for all its efficiencies, the masonry stove is actually deceptively simple.  A masonry stove is essentially a small fire chamber built directly into an encasing of stone.  This may sound mundane on the surface, but there are three key parts to the masonry stove that make it highly efficient.

First is the fact that stone is used instead of metal.  This isn’t some aesthetic decorating whim.  This is imperative.  Metal may have the advantage of heating up quickly, but it also has the disadvantage of cooling down equally rapidly.  Thus, for metal to stay warm, it has to be heated continuously which is less than desirable.  Stone on the other hand heats up more gradually, but once hot, holds onto its heat like a cop to a cup of coffee.  Essentially, the stone in the masonry stove serves as a big old “heat battery.”

As you can tell by this cross-section, masonry stoves are A-maze-ing

Within this stone encasing is a tightly-packed maze through which the heat of the fire travels on its way to the chimney.  The maze is important because it creates the time, distance and surface area necessary for almost all of the heat to be soaked up by stone before heading out the chimney.  The end result is almost no heat escapes out the chimney.

The winding, labyrinth-like air channels of a masonry stove


Hot Stuff

Lastly, the fire is able to burn at extremely high temperatures, about two to three times that of a traditional fire place (near 2000F as opposed to 700F). This has the benefit of not only extracting nearly all of the heat from the wood, but also creating complete combustion.  This means an extremely clean burning fire with almost no smoke, pollutants, or creosote (the bad stuff that causes chimney fires).  So the hot fire is actually safer as well as cleaner and more efficient. 


It’s also worth noting that even though fire burns extremely hot, the stones themselves are not scalding.  This means you can touch the fireplace without fear of needing a skin-graft like with a traditional metal wood stove.  In fact, some masonry stove designs will even include benches or beds built into them for the user to sit on.

So, in sum, what we have here is a hot, clean burning fire that minimizes pollution and maximizes heat which is then stored in and radiated from a stone storage “heat battery.” On a practical level, this means the fire only has to be lit for a very short period of time, anywhere from 30 minutes to two hours, after which heat releases continually from the stone for the rest of the day.  But the stone doesn’t just release the heat in some namby-pamby fashion.  It radiates heat.

As mentioned earlier, the fact that the heat is primarily radiated as opposed to conducted or convected like modern heating systems is key.  The properties of stone allow it to radiate heat slowly as low-frequency infrared waves.  Rather than heating the air itself, the infrared waves primarily heat whatever they come into contact with directly (the people and objects in the room), a much more direct and efficient form of heating.

This high efficiency both from the complete combustion and radiant heat translates into very meager amounts of firewood.  It might sound like poppycock, but between one and two cords of wood can heat an entire 650 square foot home for a whole year (source: low-tech magazine)!  That's approximately one tree for a whole year of heat.  Further developments of the technology allow this compact modern model offered in Europe (see picture below) can heat up to 1600 square feet.

An example of a modern masonry heater from European company Contura

Green Speak

Keep in mind that wood is not only typically cheaper than oil or gas, it’s also considerably less polluting to harvest and completely renewable and carbon-neutral if responsibly replanted.  So, if you look at the total energy chain from start to finish, harvesting to heating, the masonry stove is even more efficient than a conventional fossil fuel based heating system.  The end result is maximal heating and minimal pollution based on an inexpensive and renewable fuel source, all done using technology pioneered in the 1300s.  Not bad. 

While the technology is ancient in origin, in Europe especially, companies have continued to develop this technology into a competitive alternative to conventional heating.  Some of the results are truly impressive.  It’s also worth noting though masonry heaters are traditionally fueled by wood, they can be modified to use gas or work in concert with it.  They can either supplement or supplant a conventional heating system.  

A modern masonry heater built into a wall is both aesthetically pleasing and functionally effective

Finnish-ing Up

There are drawbacks, however.  Stone is heavy and expensive and masonry can be challenging to mass manufacture, though it is being done.  Thus, the initial upfront cost of a masonry stove may be more than a conventional heating system, but the masonry stove is so efficient, the modern-day Finnish government actually subsidizes the installation of masonry stoves in new homes.  

Masonry heaters also benefit from a relatively open floor plan to function optimally.  In the same way the sun can’t warm you in the shade, if you can’t see the masonry heater, you can’t fully feel its radiant warmth.  

Masonry heaters may not be perfect, but neither are our modern heating solutions, and for being as old as they are in origin, masonry stoves are surprisingly viable.  There is wisdom in these old technologies, wisdom worth remembering, and in some cases, wisdom worth reviving.  The fact that such an ancient technology can rival and in some ways surpass current heating solutions in terms of high-efficiency, low-pollution, and carbon-neutrality is truly amazing.  And that's not poppycock.


Sources and Further Reading:

Modern masonry stoves currently available in Sweden: http://www.contura.eu/english/

Modern masonry stove company based in England: http://www.cornishmasonrystoves.com/

In-depth article on the history and science of masonry stoves: http://www.lowtechmagazine.com/2008/12/tile-stoves.html


Basic overview of masonry stoves: https://www.niftyhomestead.com/blog/masonry-heater/

Wednesday, April 19, 2017

The 21st Century Guide To Vitamin D


Light On The Subject
Getting enough Vitamin D is nothing to bat an eyelash about; yet, despite being a key component of our overall well-being, Vitamin D can be deceptively tricky to get, especially in far-latitudes such as Alaska.  Regardless of where you are, whether North Pole, South Pole, or even Equator, this guide will arm you with the know-how to understand exactly what’s going on with Vitamin D and your body, why it’s so important, and how to make sure you’re getting enough.

You may have heard Vitamin D called the “sunshine vitamin,” nicknamed for its ability to instill a sunny mood and for our body’s dependence on the sun to produce it.  People first thought Vitamin D was mainly useful for building strong bones to ward off diseases like rickets, but new research shows the Vitamin D kicking around in your system is likely doing more than you realize, playing an important role in both your health and happiness (1).

Vitamin D receptors have been found all over the body even in the heart and reproductive organs (2,3).  That's right.  Even "where the sun don't shine" benefits from the sunshine vitamin.  In fact, “It’s estimated upwards of 2,000 genes are directly or indirectly regulated by Vitamin D” (4).  That's a lot of genes!  That's a lot of Vitamin D!  

Another way to wrap your head around the importance of getting enough Vitamin D is to look at the converse:  what happens when we don’t get enough.  Vitamin D deficiency is implicit in a host of diseases and symptoms including, but not limited to depression, breast cancer, multiple sclerosis, Alzheimer’s, and even plain old fatigue.

Clearly, from our body's standpoint, Vitamin D isn't just some optional additive we should toss in whenever we have the chance. It's an essential ingredient to our health, happiness, and overall well-being.


D-Talks
There are common misconceptions about Vitamin D, misconceptions worth detoxing from.  Even the term Vitamin D itself is a bit of a misnomer.  Despite the word “vitamin” appearing in the name, Vitamin D isn’t really a vitamin.  It’s actually a hormone (2).

You see vitamins are nutrients our bodies are unable to produce on their own, instead obtaining them from the food we eat.  Hormones, on the other hand, are body-process regulators that our bodies are able to self-produce (such as testosterone, estrogen, and adrenaline).  Vitamin D is much more akin to the latter.

Take for instance the fact Vitamin D, for the most part, doesn't naturally occur in food.  The list of foods naturally containing Vitamin D is shorter than the weekend: namely fatty fish, beef liver, egg yolk, and certain mushrooms.  Even human breast milk contains next to no Vitamin D (5).  Furthermore, in the few foods in which Vitamin D does occur, it’s in such minuscule amounts, it is effectively impossible to get enough.  For instance, to hit the Vitamin D Council’s daily recommendation, you’d have to eat well over 100 eggs every day (6).  That’s even more eggs than Paul Newman in Cool Hand Luke (in the movie, Newman ingests 50 eggs on a bet).


Newman's character ingesting 50 eggs in Cool Hand Luke.  This method is more likely to leave you with a stomach ache than adequate Vitamin D.


The moral of the story is unlike other “vitamins,” we simply can’t get adequate Vitamin D from the food we eat, but like hormones, our body can produce Vitamin D naturally.  It just needs a little help from the sun.


Bright Idea
The sun is a wonderful thing, enabling life on Earth to exist as we know it.  It comes in handy for a number of tasks we often take for granted such as setting our circadian rhythms so we wake up and wind down at the right time, generating serotonin in our brains so we feel good, and among other things, helping our bodies produce Vitamin D.

When it comes to producing Vitamin D, we are surprisingly plant-like.  In our skin, we have dormant Vitamin D precursors (actually a form of cholesterol).  Much the way a plant makes food from the sun, when UVB (Ultraviolet B) rays from the sun hit our skin, our body can then “photosynthesize” these Vitamin D precursors into bonafide, Vitamin D.  Without the sun, this can’t happen.

Not just any namby-pamby ray of sunlight will do, though.  To make Vitamin D, that ray of sunlight must, I repeat, must contain UVB rays, something our atmosphere can be pretty adept at filtering out.  This is where the height of the sun comes in.




Lighten Up
In order for UVB rays to make it through the atmosphere to our skin, the height of the sun (more formally referred to as the solar altitude, angle, or elevation) must be at least 20 degrees (7).  In other words, when the sun is 20 degrees or higher in the sky, our bodies can start making Vitamin D.  Higher is of course better, resulting in faster Vitamin D production, but a 20 degree solar elevation is the key metric where production starts/stops.

Now, the angle of the sun depends primarily on two factors: the time of day and the time of year.  During the beginning and end of the year (winter) the sun doesn’t get as high as it does during the middle of the year (summer).  Similarly, during the beginning and end of any given day (sunset, sunrise), the sun isn’t as high as it is during the middle (solar noon).  In summary, during the “middles” (both of the year and day) the sun is higher than during the “beginnings and ends.”

There’s an incredibly useful term for this middle of the day time called “solar noon,” astrology-speak for when the sun is at its highest each day.  On the equator, solar noon corresponds to time-of-day noon, but the further north or south you live, the more solar noon separates from time-of-day noon.  Currently in Anchorage, Alaska, post-daylight savings time, “solar noon” is actually about 2pm.

Being outside around solar noon is incredibly helpful for bolstering your Vitamin D production.  With the sun at its highest, this is when your body will have the best chance to produce the most Vitamin D in the shortest amount of time.

Okay, so you know the sun needs to be at least 20 degrees in the sky and better yet at solar noon, but where on Earth do you find this incredibly useful, life-changing information?

Well, you could use the length of your shadow and trigonometry like the ancients did…Or, you could head to this incredibly handy site:  

https://www.timeanddate.com/astronomy/usa/anchorage

This site will tell you everything you ever wanted to know about the sun’s positioning including how high it is. (Please note: solar altitude, elevation, and angle are all interchangeable terms for the same thing: how high the sun is in the sky.  This site likes to use the term “altitude.”)


Thanks to the magic of the internet, you too can divine the height of the sun at any given time.  Here, we have a solar altitude of 34 degrees, well above the necessary 20 degrees needed to make Vitamin D.  From: timeanddate.com


As a bonus, you can also use your shadow to approximate solar elevation (which, let's face it, is kind of cool).  This can come in handy if you're camping, in a pinch, or trying to impress prospective dates.  These shadow lengths correspond to the following solar elevations:

1. Shadow is circular blob at feet, solar angle is 90 degrees
2. Shadow is as long as you are tall, solar angle is 45 degrees
3. Shadow is 2.75 times as long as you are tall, solar angle is 20 degrees (the cusp of making Vitamin D)


Using your shadow (or your dog's) you can handily estimate the sun's height in the sky.  Useful for wooing dates and generating Vitamin D.

So, you’ve taken care of the atmosphere blocking UVB rays by getting outside when the sun’s at least 20 degrees high in the sky.  That’s step one.  But, there are other things that can still hamper UVB rays from hitting your skin and producing Vitamin D, the most fundamental offender being your clothes.

Clothes Call
If you think of your skin as a giant solar panel for generating Vitamin D, you’re on the right track.  Our skin is actually our body’s largest organ and when it comes to Vitamin D this is a boon.  The more skin exposed, the faster your body will produce Vitamin D.  Show as much skin as socially acceptable.  Take off your shirt.  Roll up your shorts.  Heck, if your location allows it, get naked.  This will allow your body to generate lots of Vitamin D in very little time.


Two exquisite(ly pale) human specimens demonstrating good Vitamin D etiquette.

Now, remember it’s the UVB rays your skin needs to synthesize Vitamin D.  So, anything that blocks UVB light effectively halts Vitamin D production.  While clothes and a low sun may be the most obvious offenders, there are a few less-obvious offenders you should know about: Glass-windows, cloud-cover, and sunscreen (8).

1. Glass windows.  The fact glass blocks Vitamin D synthesis goes a long way towards explain why so many people are deficient.  Even on a sunny day, unless that sun is streaming unobstructed (such as through an open window or screen), we aren’t making Vitamin D when indoors.

2. Cloud-cover.  Though an overcast day can block UVB light, it’s worth noting that a partly cloudy day can actually amplify it due to the scattered clouds acting like mirrors.  Similarly, snow on the ground or water can also reflect UVB rays, increasing Vitamin D production rather than hampering it.  In general, if the clouds prevent you from seeing your shadow, you can’t produce Vitamin D (9).

3. Sunscreen.  This is a big one.  If you’re wearing sunscreen you aren’t producing Vitamin D.  It’s also worth noting the shade of your skin also acts as a semi-natural sun block.  A darker skin type will block more UVB.  This doesn’t mean darker skin types can’t produce Vitamin D, just that they require more sun exposure to do so (8).

Now, at this point, you may be thinking:  But everyone’s told me to wear sunscreen my whole life!  There’s even a famous song about the virtues of wearing sunscreen!  Now you’re telling me NOT to wear sunscreen?  What kind of blasphemous skin-cancer promoting buffoon are you!

You would be right for having these concerns even if your rhetoric may have gotten a little carried away.  Thankfully, you don’t have to choose between a life of skin-cancer and Vitamin D deprivation.  According to the Vitamin D Council, you can generate ample Vitamin D in only half the amount of times it takes for your skin to turn pink (8).  The exact length of time this ends up being will depend on the solar elevation, but the key is you don’t get have to get a sunburn.  You don’t even have to turn pink!  However many minutes it would take your skin to turn pink, cut that in half and you’ve made ample Vitamin D.  After this, please, by all means, slap on some sunscreen!


Certain reflective surfaces like snow, water, and even partial cloud cover can actually enhance the UVB exposure needed for Vitamin D production.


Light Reading
So, the sun is at least 20 degrees in the sky.  You’re showing some skin, all while making sure not to accidentally block any UVB rays with glass or sunscreen.  Now, you may be thinking, geez that’s a lot of work!  Why would I go through all that when I could just take a supplement from the supermarket?  One of the main reasons is self-regulation. 

The cool thing about when your body generates Vitamin D from the sun is it automatically self-regulates.  Your body will produce only as much Vitamin D as you need and stop when you have enough, automatically optimizing your Vitamin D levels for you.  This is especially beneficial because it is possible to get both too little and too much Vitamin D, neither of which is good for you.

With supplements both of these outcomes are a possibility.  It can be easy to get inadequate amounts due to absorption problems (to facilitate absorption, it is recommended to always take Vitamin D supplements alongside a source of fat, since Vitamin D is fat-soluble substance, meaning it takes fat to dissolve).  It can be challenging to get enough if your body simply isn’t absorbing the supplement, and there’s no real way to know short of a blood test.

If you aren’t getting enough, you can increase your dosage to compensate, but it’s also possible to get too much Vitamin D and experience a condition called Vitamin D toxicity where soft tissues like blood vessels and organs begin to harden (14).  This is because supplements contain a form of already activated Vitamin D.  Once absorbed, your body has no choice but to use it, essentially being force-fed Vitamin D.

This isn’t to say supplements are bad (in fact, sometimes they are entirely necessary), only that dialing in the correct dosage of Vitamin D can be an experimental trial-and-error process: You try a certain dosage, check your Vitamin D levels with a blood test, readjust your dosage, and repeat until your levels are optimal.  To say the least, it can be a tedious process.

As you can see, one of the main benefits of getting Vitamin D from the sun (besides it being the way our bodies were designed to receive it) is you don’t have to worry about any of the above.  With adequate sun exposure, your body will self-regulate, automatically producing optimal levels of Vitamin D making sure you are neither deficient nor toxic (11).  All you have to do is enjoy the sun.


Pictured: An Alaskan sunbathing in their natural habitat


Northern Exposure
However, especially in Alaska and other far-latitudes, it isn’t always possible to get adequate levels of sun exposure.  Producing Vitamin D from the sun while preferred, sometimes simply isn’t an option.  In Anchorage, Alaska from October 15th to February 25 it is impossible to generate Vitamin D from the sun (12,13).  Between these dates, it is absolutely essential to use supplementation.

The Vitamin D Council recommends between 5,000 IU (International Units) and 10,000 IU a day (10).  Personally, when taking 5,000 IU during the winter I still came up deficient.  It was 10,000 IU this past winter that landed my levels at not only adequate, but optimal, weighing in around 50 ng/ml.  I would recommend (obligatory I am not a doctor statement) starting with 5,000 IU and then have your levels checked at a health fair or by a doctor mid-winter, bumping up to 10,000 IU if your levels are still lacking.  It’s important to note that previously, Vitamin D blood levels of 20 or 30 ng/ml were considered adequate, but this was based off old research primarily focused just on preventing rickets.  Current research shows optimal Vitamin D blood levels are closer to 50ng/ml (10).

In addition to the amount, the type of Vitamin D is also important.  The best kind of Vitamin D to supplement is Vitamin D3 since it is the same as the type of Vitamin D your body would naturally produce were it exposed to the sun.  Vitamin D2 is the inferior kind that the body seems to have more trouble utilizing due to it being more akin to a foreign substance.

Vitamin D3 comes from two primary sources: fish skin and oil from sheep wool.  The oil from sheep wool (lanolin) has a similar Vitamin D precursor to our own skin.  This precursor containing oil is wrung from the wool and then artificially exposed to UVB light in order to activate it.  The Vitamin D found in fish skin is already activated coming from the plankton they eat.  However, fish are at risk for mercury exposure and also contain ample amounts of Vitamin A, which can become toxic in high amounts. Because Vitamin D from sheep wool oil doesn't share these complications, most Vitamin D3 comes from sheep wool oil.  This is widely considered to be the best and safest kind (15).

Sunning It All Up
In summary, Vitamin D is a quintessential hormone integral to our health, happiness, and well-being.   Thanks to the body’s built-in self-regulation, Vitamin D produced by the sun is the most natural, quickest, and safest way to obtain and maintain optimal levels.  At least a 20 degree solar elevation plus some bare skin is all you need to start making Vitamin D.  For optimal Vitamin D production, aim to be outside around solar noon. 

While Vitamin D from the sun is the best, during certain times of the year, when the solar angle is less than 20 degrees, Vitamin D simply can’t be made from the sun.  During these times, supplementation becomes absolutely necessary, in which case 5,000 IU to 10,000 IU of Vitamin D3 taken alongside a source of fat often does the trick. 

So what are you waiting for?  Get out there and make some Vitamin D!  I hope this article has been enlightening.

This article was written in the sun whilst soaking up Vitamin D.

Sources: