Pages

Monday, June 8, 2015

CG Earth

Click to view larger

You may have noticed that my blog background changed a couple days ago. I've been meaning to change it for quite a while, but I didn't get around to it. Then, a few days ago, I had some free time on my hands. Why not create a 3D model of Earth, I wondered? So I pulled up Blender (a free computer graphics program I use) and got to work.


I actually wasn't entirely sure where to begin, but I had an idea of the basics. I needed to:
  • Map some terrain onto a sphere
  • Make an atmosphere
  • Create clouds
  • Prevent the clouds from looking like a weird shell around the planet
I'm not fully fluent in all the different techniques and features for Blender, so I looked for a planet Earth tutorial online. I soon found a BlenderGuru tutorial describing how to create and render a model of the planet Earth.

The problem with the tutorial is that it was for a different version of Blender, and as a result didn't do everything I wanted to do. I watched most of the tutorial, did some more Google searches, and figured out the rest on my own.

The final result consists of three layers of spheres of different sizes. It sounds pretty simple, but the important part is how I treat those layers.

The first layer is the actual surface of the planet. To make it as accurate as possible, I mapped NASA image data onto its surface. This required a total of 4 different images; I downloaded all but one of them directly from nasa.gov. The images were extremely large (many megabytes, many pixels), so I scaled them and compressed them until they were less than 5 MB each.

The main image, of course, is the following cloud-free "blue marble" map of earth's surface:

Land, sea, ice; used as a color image

I used this image to color the planet. NASA also included some other maps of the surface, but they were inaccurate because they did not include the polar ice caps, so I went with this one.

The next image I used was a map of surface topography. In this image, brighter pixels represent higher elevations and darker pixels represent lower elevations. I used the image as a normal map for shading. Basically, it puts shadows on the sides of mountains.

Topography; used for surface normals

The next image is a specularity mask. It's black where there's water, and white where there's land. I got this texture from blenderguru.com, because NASA didn't seem to have it. I used the image to determine which parts are reflective and which parts are not. The ocean should be shiny in sunlight, but the land should not.

Water map; used for specularity mask

Last but not least, I needed a map of city lights for the night side of the planet. I started with this image:

Earth at night

I started by mapping the image to the dark side of the planet. The problem is that the image also contains some blue, so the dark side of the planet was actually producing its own blue light. It didn't look bad, but it was unnatural. So uploaded the image to GIMP, where I removed the blue and converted to greyscale. This was the result:

City lights; used for light emission

...which is a map of the city lights, and practically nothing else. I used this final image to map some glowing points of light onto the dark side of the planet.

That finished the first layer. You might not have noticed all of those details, but the final result wouldn't have been the same without them.

The next layer is the cloud layer, which was much simpler. I only used one image:

Clouds, used for color, transparency, and surface normals

I used the image data for color as well as transparency and normal mapping. That way, the sphere is opaque where the clouds are, and transparent everywhere else. The clouds are also grey in places, and have a bumpy texture.

The next layer, the largest sphere, is the atmosphere. I didn't use any images for this sphere; instead, I used volume scattering to scatter blue light, and some math to make the atmosphere fade away at the edges. The resulting atmosphere is actually unrealistic – Earth's atmosphere doesn't extend this far from the surface. I decided to do it this way, though, because it looked better.

That's the basic idea for how I designed my 3D CG Earth. All I had to do next was add a background. Then, after rendering the final image, I applied JPEG compression in GIMP, and I was done.

So that's how I created the new background for my blog. What do you think? Comment below!


New posts every month – subscribe for free!


5 comments:

  1. Its great! I can barely see that its not real! Does blender make a new version every year?

    ReplyDelete
    Replies
    1. Thanks for commenting! Blender releases a new version whenever a new version is finished, which is usually every few months.

      So far this year they've released 2 versions. The new versions generally contain minor updates like bug fixes or speed improvements, but occasionally they'll add a big new feature like support for Cycles volume rendering.

      Delete
    2. Yea I was thinking about getting it but the last time I tried it had a virus.

      Delete
    3. Really? I don't think Blender has ever had any viruses, so it was probably a false positive. If you download the .exe directly from blender.org, you're safe.

      I read that some virus scanners were giving false positives because one of the filenames used by Blender is also commonly used by real viruses; that may be the issue. I've never had any trouble with Blender.

      Delete