Topics

Showing posts with label terminator. Show all posts
Showing posts with label terminator. Show all posts

Thursday, June 21, 2012

Making of a Planet - Part 2

In this post, I'll be describing in more detail how the CG Earth is constructed.

The whole planet was broken down into several key components: land, water, clouds, atmosphere and an atmospheric "rim". The atmosphere has two components because it's not a true volumetric simulation, but a kind of hack ^^;


Land 

Nothing fancy here that's not been done for decades. A simple sphere primitive with polar (spherical) UV projection so that the Blue Marble textures can be wrapped around it. Of course, it's well known that the Earth is not a perfect sphere, but an oblate spheroid. This is approximated using an Equatorial radius of 6378.14km and Polar radius of 6356.75km

An early "making-of" montage showing the key components of the Earth setup

A displacement shader is used with elevation data to create the mountains and terrain above ground, and bathymetry data is used to create the ocean floor below sea level.

Water

This is just another sphere primitive with an ocean shader applied. Water reflects the sun with a much stronger specular glint than the land or clouds. In the final version, however, I ditched both the bathymetry and water components and instead included the ocean shader into the single land shader for the entire planet. This was done to optimize rendering since the sea is really not that transparent from space, therefore calculating displacement for the sea floor is a waste of render time.

Clouds

After much experimentation with various volumetric hacks, I eventually settled upon the same age old technique everyone else is using - a sphere (surprise, surprise) mapped with transparency data from NASA's cloud texture, with the same cloud map doubling as a displacement map to give the clouds actual thickness. On top of this, I added procedural noise for detail, since the cloud map is of noticeably lower resolution than the land texture. To be honest, I feel that I have failed in the implementation of this component most miserably, so future versions will likely be done differently.

Displacement mapping to give the clouds thickness; procedural noise to add detail

Atmosphere and Rim

Another key component that makes or breaks the look of a CG planet is the atmosphere. The atmosphere of the Earth interacts with sunlight to produce a multitude of lighting effects and localized color shifts. Indeed, it is reason why the sky is blue and why the Sun appears yellowish when viewed from the ground. 


No atmosphere
With atmosphere

The volumetric effect is created using a set of concentric sphere of increasing size and decreasing opacity. The Rayleigh scattering effects is creating using ramp lookup based on a modified Lambert angle. As the shading approaches the terminator, the light color turns reddish.



The other component is the atmospheric rim, which uses another ramp lookup to create the blue "outline" around the limb of the Earth.



I must confess the most of the effects are hacked - they are "physically informed", but not physically based. At this point in time I'm still researching true volumetric solutions for the clouds and true scattering for the atmosphere.

The sane Rayleigh ramp lookup is used to color the cloud layer. A crude but effective technique ^^;;

Size Matters

As mentioned previously, all modeling was done to relative scale as much as possible in the spirit of "realism". Initially I used a unit of 1km but the comparatively small details of Earth and the astronomical scale of the solar orbit appear to cause precision problems when rendering shadows. No amount of tweaking the raytracing bias worked. In the end, through trial and error I found that using a base unit of 10km seem to minimize the glitches. So, for example, instead of 6378.14 for the Equatorial radius, I used 637.814

In the next post, I'll talk about the various shaders.

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):