Topics

Saturday, November 26, 2011

Terminator Too

While still on the topic of the Earth's terminator, let's talk about another of its distinct feature - the red color due to atmospheric Rayleigh scattering. From the surface, we experience the reddening as sunrise and sunsets. Here's a reference photo of the Earth's terminator taken from the ISS on 12 Apr 2011:

Sunset over Western South America (source: NASA)
Clearly a photorealistic CG Earth would need to replicate this feature. The following are test images dated 11-16 Oct 2011:

A tell-tale sign that an Earth image is CG - no reddening at the terminator line

Sunset colors at the terminator line, but still poorly implemented and highly unconvincing ^^;;
A higher resolution, tone-mapped work-in-progress shot of the terminator reddening

Friday, November 25, 2011

Gamma Terminated

Let's talk about terminators and gamma. No, not the human-killing robots from the future, but the line dividing light and shadow on a lit object. And not the gamma radiation that turned a scientist into an angry green giant, but the non-linear behavior of our eyes and optical devices to light intensity. Finally, we'll take a look at how the Earth's terminator is unique from, say, the Moon's terminator.

This article from GPU Gems 3 explains gamma correction and the importance of linearity when creating rendered images. Basically, our eyes, cameras and display devices all do not respond to light in a linear fashion. Our eyes are more sensitive in low-light conditions and can see more variations in intensity than in very bright environments. Similarly, the brightness output of a display device does not respond in a linear fashion to the voltage input, being dimmer at the lower intensity ranges than the correct output should be. Because every device has a different gamma response, the same input image may appear very different on different display devices.

Hence, gamma correction has been introduced to ensure that what we see on our typical display (e.g. LCD monitor) looks visually correct compared to what we would see using our naked eye. This blog article from Beautiful Pixels (where the following image originates) offers a good example of what a gamma corrected render should look like:

From left: uncorrected CG sphere, photo of half Moon, gamma corrected CG sphere
For a solid diffuse surface, the natural appearance would be to have a clearly delineated terminator where the transition from light to dark is well defined.

Viewed from space, the Earth's terminator should also be well defined, as confirmed by photos of the Earth taken from spacecrafts and Apollo astronauts. So then, what's so special about the Earth's terminator?

When light is shone onto a sphere, the terminator line would divide the sphere into exactly two halves - half in the light and the other half in darkness. However, in the case of the Earth, the sunlit portion is actually greater than the night portion. This can be observed as during the equinoxes, there are more than 12 hours of daylight in a 24 hour day. How is that so?

The answer is the Earth's atmosphere. It actually bends light by about half a degree (60km) into the area of the Earth that would otherwise be dark. Also, the atmosphere scatters light across the sky so the ground would not be in total darkness even after the Sun has set.

You can check out which parts of the Earth is currently in day and night here. After looking at the pretty picture, do read the notes for some very good explanations. You can map the picture onto a 3D sphere and confirm for yourself that the terminator line slightly over the halfway mark.

The following is my attempt to capture this effect by modifying the illumination equation in shaders (image dated 7 Oct 2011):






Friday, November 18, 2011

The Known Earth

I had been searching for reference material for what the Earth looks like from deep space, but could not find enough photographic reference. About a month ago, a friend pointed me at this amazing video called "The Known Universe" developed by the American Museum of Natural History in partnership with the Rubin Museum of Art. It was rendered using Uniview, a real-time astronomical visualization engine that created all the imagery based on scientific data. Do watch this amazing video that shows the extent of our knowledge of the Universe starting from the Himalayas within Earth's atmosphere out to the most distant cosmic microwave background radiation billions of years in the past as recorded by WMAP (the youngest baby pictures we have of our Universe):


Inspired by the video, I adjusted my palette to achieve the following look for my CG Earth. I purposefully chose a camera angle that matched one of the shots in the above AMNH video. If the imagery looks similar, it's because we both used NASA's BMNG data. The clouds are the same configuration, but I was using topography data from January 2004 (still winter in the northern hemisphere) and they are probably using a summer month. However, this is still not the photorealistic look I was going for (image dated 14 Oct 2011):


Recently I came across a huge online collection of Hasselblad photos from the Apollo missions. Even though the color fidelity of the photos are highly inconsistent, I now have access to literally hundreds of reference images of the Earth taken from deep space. I can now spend days balancing the look development to better match reality (assuming the Moon missions and the photos are not hoaxes that is :P)

More to come...

Views from above (random WIP shots)

These are intermediate work-in-progress images with some light post-processing done (dated 20 Oct 2011, first posted on Facebook): 

Above a Cloudless Sky
Most CG Earth renders have to reduce the amount of clouds or lower the density of the air (or omit the atmosphere altogether) so the Earth can look more recognizable to the average viewer.

Personally I like how the atmospheric scattering gives the Earth a soft translucent feel, though having little reference material to draw upon, I can only imagine how things actually look from further distances than the ISS and Space Shuttles have gone.


Clouds really ruin the look of the sky, especially from space. According to NASA, about 70% of the Earth is covered by clouds on an average day, which means we don't get to see much of the continents and ocean like we are used to seeing on maps and in atlases.

The atmosphere also tints the ground a shade of blue (due to atmospheric scattering) and sometimes occludes it altogether (an effect known as extinction, usually to describe the invisibility of stars from the night sky due to the Earth's atmosphere)

I'm still trying to figure out how to create nice volumetric clouds in CG...

Airglow and City Lights
One of the more interesting things I observe from ISS videos on YouTube was the "airglow" which was clearly visible as a thin yellow-green line at the top edge of the Earth's atmosphere for night exposures.

The colors of the "night side" of my CG Earth was set up to match the look of those videos. Since I'm using a linear workflow, this night shot had to be exposed correctly or else it's just a black image with faint yellow spots. This image was converted to 8-bit JPG from 32-bit EXR render:


A Thin Crust
The Hiimalayas are the tallest mountain ranges on the planet, about 6-8000m above sea level, yet they don't look as jagged from space as we might imagine. Many CG Earth renders has to exaggerate the elevation by an order of at least 3 times to get a decent effect. I kept to relatively realistic values so the mountains don't really stand out.

If the Earth is the size of an apple, the entire Earth's crust would be thinner than the apple skin, which means the highest mountains like Mt. Everest won't even pop out like a pimple ^^;;


Tuesday, November 8, 2011

Atmosphere development

After some research into physically based atmospheric models (Nishita... etc) I realized that while I understand the basic principles behind calculating optical depth, Rayleigh and Mie scattering, I don't have the necessarily Math or shader building skills to recreate them properly and optimally in Houdini. Yet :P

So meanwhile, I'm using an artist's approach. Essentially I'm "pre-computing" the scattering of different wavelengths as well as optical depth due to incident viewing angle and storing them as colors on a color ramp. It's really not as complicated as it may sound, and apparently it's a similar technique used by game programmers to render planetary atmospheres in real time (though I came up with the idea independently before reading about a similar method here).

There are two main components to the scattering:
  1. Rayleigh scattering which scatters blue wavelengths more than red, mostly responsible for blue skies and red sunsets.
  2. Mie scattering which scatters pretty much independently of wavelength, but with a strong bias towards forward scattering making the sky appear brighter around the Sun. This is really only significant if I were rendering a view of the sky from within planet's atmosphere, which I haven't planned on doing just yet :P

The scattering is dependent on the optical depth through which sunlight travels within the atmosphere, and caused by small air molecules in the case of Rayleigh and larger particles and aerosols in the case of Mie. Generally, the more distance that light travels through the air/aerosols, the more the light attenuation and scattering effect. As more blue light gets scattering in all directions, the originally white light from the Sun appears more yellow, then red (during sunrise and sunsets). The actual calculations are further complicated by phase functions which are both light and view dependent, but I've attempted to incorporate those effects into the color ramps also.

Here's how I implemented the atmospheric scattering effects:

Looking at the entire planet from far, the optical depth is minimum at the center of the planet and gets thicker as we move toward the outer edge. This is characterized by less scattering in the middle and more scattering at the circumference, which can be easily approximated using an edge falloff function modulating the opacity of the atmosphere layer.

Terminator redness has been exaggerated for visibility

So far, this only captures the scattering component from points on the Earth's surface through the atmosphere toward the viewer's eye (Earth to Viewer). On top of this, we need to add a light dependent component, which is the scattering along the optical path from the Sun through the atmosphere to the point on the Earth's surface (Sun to Earth). Once again, I used an artist's "hack", employing the standard Lambertian dot product (L.N) and using the resultant to lookup another color ramp. This was used to achieve the "red terminator" characteristic of planets with red sunsets.

The last step would be to achieve the rim falloff from bright sky blue to the blackness of space, and I have chosen to recreate this using a separate layer from the atmosphere (which employs a multi-layered volumetric approach mentioned in this post). This is also achieved using an edge falloff function driving a color ramp:

Color ramps - a CG artist's best friend when it comes to creating shaders without programming
 
In a later post I will explain how I implemented atmospheric density falloff based on altitude - i.e, the air gets thinner the higher up you go.

Tuesday, November 1, 2011

The Bahamas (random WIP shots)

Here are some more random work-in-progress images (dated 10 Oct 2011). 

Facing SE we can see the tip of Florida at the bottom and Cuba (big, long island starting from the bottom right). The chain of smaller islands to the North of Cuba (i.e. to the left in the images) is the Bahamas, popular tourist spot and corporate tax haven (perhaps not these days) :P