How Art and Science Meet in the Sky
Many of us have been working on the sky and lighting for our game these last couple weeks. Joes last Dev Log described the various technical features of our sky colors, so Ill talk a bit about the art side.
One thing I noticed when I started working on the sky coloration is that I really had very little idea of how the skys colors evolved over the course of the day. I knew it was blue during the day, with a lighter blue toward the horizon, and I knew that sunset involved lots of purple and red and orange, and thats about it. What about before all the sunset fireworks? What about after the sun had gone down? No clue.
I also didnt have a good sense of what PARTS of the sky are what colors during a sunset. Are the clouds orange on a purple background, or are they purple clouds on an orange background? Heres another question I found myself stuck on. When Im looking at a photo of a gorgeous sunset with the sun somewhere in the scene, what does the OPPOSITE side of the sky look like? If I turned around, what would I see? Would it look the same? Would it be darker? Would it be different colors?
Thanks to the dual miracles of the information superhighway and digital cameras, I was able to find out. For about a week I was a madman with the FLS digital camera. At night when the sun was setting, Id run out every 10 minutes and take pictures of as much of the sky as possible, both on the front balcony and in the back.
Here is one of the amazingly illustrative photos I took looking up from our balcony. In the very bottom right, you can see a tiny edge of our building.
Heres a slightly more helpful photo I took at twilight.
Using these resources I was roughly able to determine how the color of the sky changed over time. I also observed enough sky colors that I formed the General Theory on What Color the Sky Is, or GTWCSI for short. GTWCSI states that no matter when or where you look at the sky, youre seeing a portion of the rainbow spectrum. It theorizes that you will never see red and blue in the sky right next to each other theyll always have orange, yellow and green between them.
Well, any idiot can tell you that theres no green in the sky. Or is there? The rainbow spectrum goes from red to yellow to green to blue. This is the order of the wavelengths from longest to shortest of the visible light range of electromagnetic radiation. Visible light is energy, just like heat, x-rays and cell-phone conversations.
Physics tells us that the sun is the source of all the colors we ever see in our sky, and the Sun is what is known in physics as a black body radiator a fancy science term that says the hotter the body is, the higher frequency radiation it emits. Well, weve just said that red is the lowest frequency in the visible spectrum, and blue is the highest. Anyone who has played with fire as extensively as I have knows that the hottest part is the blue flame you see at the core, surrounded by white hot coals, and then as it gets cooler it becomes yellow, orange, red, and finally the hot, but invisible infra-red.
Well, wait, what happened to green? And where did this white come from? As it turns out, black bodies dont emit energy in just one wavelength, they do so in a gradient. So if your temperature peaks in the blue part of the spectrum, youll be emitting some light in ultraviolet, most of your light in blue, and some in green and red resulting in something that basically looks blue. If you peak in red, then you get some light in blue and green, most in red, and some in infrared. If you peak in the green portion, however, you get some in blue, most in green, and some in red. At this point, youre combining red, green and blue. These three colors combined in equal part give you white.
So when you look up at the stars at night and you see red stars, blue stars and white stars, what youre ACTUALLY seeing are stars that peak below red, above blue, and in green. The green stars just emit so MUCH energy in all three that they appear white to the human eye.
What does this mean for sunsets? Is there green, or isnt there? Heres where we get existential:– Green is green. – Green is also white. – Green is ALSO grey.
We see plenty of white in the sky near the horizon at noon, for instance. We also see grey, although it tends to hide in plain sight. Grey shows up in sunrises and sunsets, but its never noticed since its surrounded by fantastic reds and oranges.
And in fact, there are also times where its fairly obvious that there is green in the sky. Looking back at the photo of twilight above, theres a very distinct band of pale green right there between red and blue.
That was my first revelation. Green in the sky who would have thought? So the next time youre out looking at a beautiful clear sky at dusk, just remember that I am out there somewhere thinking of perfectly radiant bodies, damning my college physics professors for preventing me from enjoying the simple beauty of a sunset. And what does the GTWCSI really have to do with Pirates of the Burning Sea? Well, nothing really, but Im a game designer, so I come up with theories for everything.
My second revelation was sunrises. For a long time, I was looking at screenshots of skies from other games saying to myself, huh, thats a funny sunset. Its all pastel and stuff. I wonder if thats just an art-directors decision somewhere down the line that they should have these highly abstracted sunsets. Then about a month ago I had to drive to the airport at 5am. Imagine my surprise when I noticed that the sky looked EXACTLY like those screenshots I’d seen. Stunned, I realized that since work starts at 10am around FLS, I probably hadnt been AWAKE for a sunrise in years. Sunrise times of day are for people who go jogging, who eat breakfast, or who go to school activities which I assiduously avoid.
Armed with my new knowledge, and a better appreciation for the beauty of the sky I threw myself at the challenge of capturing a fragment of this natural splendor in our game.
I decided relatively early on that my feeble brain was not up to the task of guessing the subtle color combinations present in the sky at any given time, so I derive our sky colors directly from photos.
Heres the process I used for the twilight image:
The photo I started with:
First, I found a nice column of clear sky that went as deep into the horizon as possible, and I cropped out the rest of the image.
Then I cleaned it up a bit to remove horizon objects, and evened out cloud artifacts. At that point, I had a nice smooth color gradient from top to bottom.
This first gradient then is the color of the sky when youre looking toward the sun. I created a similar gradient to serve as the color of the sky when looking directly away from the sun a little darker, a little deeper in the color spectrum.
Then I simply did a linear horizontal blend from one gradient to the other.
Next, I mirrored the texture horizontally so that the center became the sun direction, and shrank it down to 32×128 pixels. Mirroring it wastes a little bit of memory (10k) if its exactly the same on both sides, but it allows me the ability to put in slight variations from side to side.
The only remaining step was to create an alpha channel for this texture. Alpha channels in this texture allow me to define whether or not stars are visible, and how bright they appear. The alpha channel is solid white during the day (the sky is opaque), and solid black at night. In the transitions, like twilight, the alpha channel will be darker near the top and to the sides of the texture, and brighter in the bottom center, which results in stars visible above and behind you if youre looking at where the sun just set.
The resulting texture is a 20k, 32×128 pixel, 32-bit .tga file that we stretch across our entire 10km diameter skydome. And I think to nice effect :).
Thank you for reading, and if any of you know how to get a theory considered for the Nobel Prize, please call me at The Lab.