Saturday, September 29, 2012

Modeling Earth's Atmosphere

In order to realistically simulate the appearance of the sky, I need an accurate model of the composition of the Earth's atmosphere. To this end, I implemented the U.S. Standard Atmosphere 1976, using the original paper from NASA, NOAA, and the USAF. I could have used a simple exponential density falloff, but that wouldn't have been as accurate, or as interesting to implement. I also could have used an existing implementation of the U.S. Standard Atmosphere, but I wouldn't have learned as much from that, and it wouldn't have been very fun.

The U.S. Standard Atmosphere uses SI units, and I converted to SI any values that were provided in other units. I also had to spot a few errors in the paper, where incorrect values were provided. It's fun working on a project that uses real-world units and measurements. Not just fun—it's also necessary to achieve the correct results.

Image found on Wikimedia Commons

Wednesday, September 26, 2012

Rayleigh Scattering

The coloration of the sky is primarily a result of Rayleigh scattering. Rayleigh scattering describes the scattering of light by particles much smaller than the wavelength of the light. In the case of the sky, light is scattered by the molecules of air themselves. The amount of scattering is inversely related to the fourth power of the wavelength of the light. This means that bluer light is scattered much more than redder light, which results in the blue color of the sky. And when the sun is near the horizon, its light needs to pass through more atmosphere to reach you, so even more blue light is scattered out of the path, and mostly just longer wavelengths remain, giving the sun it's vivid orangish color.

I implemented Rayleigh scattering from the ground up, including scattering cross sections, scattering coefficients, and phase functions. I am aiming for physical accuracy (and trying to learn about the physics) so I even included subtle factors such as dispersion of both the index of refraction and depolarization factor of air. The main resource I used in implementing Rayleigh scattering was this paper.

Tuesday, September 25, 2012

First Render

This is the first render that I saved. The green thing is a giant sphere (the Earth). The white thing is another giant sphere (the outer edge of the atmosphere).

Monday, September 24, 2012

Photorealizer Framework

I am writing the simulation in C++. I put together a starting framework using some pieces from Photorealizer, my own 3D renderer which I wrote from scratch. The framework includes a basic Qt GUI, some image processing features (including anti-aliasing, gamma correction, and writing bitmap image files to disk), a basic linear algebra library, code for ray-casting from the camera, code for generating sampling points on the sun, and various other utilities.

Saturday, September 22, 2012

New Project

I recently started working on a physically based sky renderer as my senior project for my Digital Media Design major at the University of Pennsylvania.

I got the idea for this project one day while was staring out the window pondering senior project ideas, and noticing the pretty sunlight, sky, and clouds.

I will write from scratch a physically accurate, brute force simulation, based on the most accurate physics and data that I can get my hands on. This will involve writing a spectral renderer, modeling the atmosphere, simulating atmospheric (multiple) scattering, and much more.

If time permits, I will even add clouds. While one of my goals is to make a physically accurate simulation that matches real-life data and references, another of my goals is to produce pretty pictures of skies, which can be greatly enhanced by the presence of clouds.

With my finished renderer, I should be able to render blue midday skies, pretty sunsets, the shadow of the earth in the atmosphere during twilight, the blue glow of the atmosphere as seen from space, crepuscular rays, and more. I would like to make it more realistic than existing sky simulations in computer graphics. It will easily be far more flexible than any analytic sky model in computer graphics, albeit much slower.

I'm not implementing any particular paper. So far, I've learned a lot from Wikipedia, and I've gotten some ideas from graphics papers. However, the main resources I've used so far come from government organizations including NASA, NOAA, USAF, and NREL.

I will post details and progress updates to this blog in the coming weeks and months.