Topics

Sunday, September 9, 2012

Making of a Planet - Part 4 - Simple atmosphere shader


Here's a good place to start if you need some instant texture maps for creating a CG Earth: JHT's Planetary Pixel Emporium. The color, bump and specular maps are self-explanatory, although in my case I'm using true displacements instead of bump. You can also get the Blue Marble textures from NASA's Visible Earth here.

The tricky part is to create the Earth's atmosphere. From reference photos, we can see that due to the curvature of the planet, the atmosphere appears more visible along the circumference compared to the center.


To achieve this effect, we can make use of the facing ratio of the surface toward the camera. Referring to the diagram below, when the view vector and the surface normal is in line, the facing ratio is 1, when they are perpendicular, the facing ratio is 0. Surfaces that face away from the camera are not rendered, so need not be considered. As such, the facing ratio at any point always fall between 0 and 1:


There are different ways to obtain the facing ratio. Maya has a very useful Sampler Info utility node which will provide that information. In Houdini, it is simple to build using the Eye vector (I) and the surface Normal vector (N). Just do a dot product, which will give you the cosine of the angle between them as long as the vectors are normalized. When the angle is 0° (I aligned with N), the cosine is 1. When the angle is 90° (I perpendicular to N), the cosine is 0°. Remember to normalize both N and I, and also, since I is the direction from Eye (camera) to the surface, it has to be negated. Finally, an Absolute node is used to ensure that the output values are positive. The SHOP network is shown below:


The network above will shade any object as if there is a headlight attached to the camera (surfaces facing the camera are brighter and surfaces facing away are darker). From there, we will adjust the output into a suitable type and range using a bit of math. The diagram below illustrates what we are trying to achieve:


The following SHOP network does exactly the above:


The Complement node inverts the black and white facing ratio, and the Power node (exponent of 6 used in this example) adjusts the intensity. A Constant of type "color" set to a suitable shade of blue is multiplied with the output of the Power node to get the blue tinted version, which is then output as the Surface Color. The output from the Power node is fed into the Surface Opacity output to allow for transparency.

Let's apply this shader to a new sphere object slightly larger (1% larger in this example, using a uniform scale factor of 1.01) than the original Earth sphere :


Of course, this is just a starting point. There is immediately the problem of the atmosphere being lit even along the shadowed side of the Earth. This is easily remedied by multiplying the output color by a shadow term, or by a self-shadowing diffuse shader such as Lambert:

The example below uses a Lambert diffuse intensity of 2

While this is more physically correct, the previous unshadowed version looks aesthetically more pleasing, which is why many planetary artists invoke artistic license to bend the laws of physics. Alas, our goal is photorealism, so we will stick with the correct look for this kind of exposure levels. Just remember it is a viable option because the stars (and sometimes the Moon) always provide faint illumination to the night side of the Earth.


1 comment:

  1. Hi Siepiau,

    My name is Joaquim Santos and I'm about to do a planet Earth for use in a Masters Project. It will be a short (10 secs or slightly more) shot and I'll use some trickery like focus/defocus to try and get away with some stuff...
    Your blog is a treasure trove of information but even so I would like to ask if by any chance I might email you if I get into some dead end?
    I'm also using Houdini so your blog and explanations are a real plus!

    If you want to see some of my work, please go to ttp://js-vfx.com

    Thanks and keep up the awesome work!

    Joaquim

    ReplyDelete