• Blender 2.77a Tutorial - Creating The Earth (Basic) (5-19-16)

    Contents:

    1. Intro
    2. Installing Blender
    3. Blender Basics
    4. About the Window Configuration
    5. Getting Started
    6. Compositing
    7. Setting up the Background
    8. Rendering
    9. Adding Textures: the Stars
    10. Adding Textures: the Earth
    11. Refining the Composition
    12. Fine-tuning the Render
    13. Rendering an Animation
    14. Wrapping Up

    Intro:

    This is an introductory tutorial aimed towards beginners. It assumes no prior experience using Blender. If you would like to create a more realistic Earth, check out my advanced earth tutorial (which does require a basic understanding of how to use Blender).

    Blender is one of the most amazing, if not THE most amazing, open-source software programs out there. I make this claim based on the crazy amount of stuff you can do in Blender (all for absolutely free): 3D-modeling, animation, compositing, sequencing, UV-texture mapping, simulations, game creation, and complex rendering capabilities are all standard features. If you need more functionality, you can even write your own Python scripts (since Blender is written in Python, which makes it even more awesome). For example, if you wanted to generate a side-by-side visual comparison of different stars based on their mass from a data set, you could! We’ll be sticking with the space-theme for this tutorial but will be doing something a bit easier: modeling a basic version of the Earth. :earth_americas:

    Installing Blender

    Blender is released in packages for Windows, Mac, and Linux. We can find the most recent releases on the Blender download page. To install on Windows, you simply download and run the installer. For linux, you can either: 1) download and extract the tarball from the downloads page, or 2) use apt-get (note that the second method will likely install an older version of Blender, so if you want the newest version you’ll need to use method 1):

    
        sudo apt-get install blender
    
    

    The Blender version this tutorial was written with is 2.77. Once you have blender installed, open the program (if it didn’t open automatically after installation) by either typing “blender” into a terminal in Linux or by clicking on the icon in Windows. You should be greeted with a splash screen and the default project, which contains a cube, lamp, and camera.

    Blender Basics

    If you’re using Blender for the first time, be warned that it can be easy to get frustrated (based on my own experience starting out several years ago). The key to maximize your ability to work fluidly in Blender are to memorize keystrokes for common actions you’ll do (like rotating an object and inserting keyframes) and to use a three button mouse if possible. I will go over some of the keystrokes/ mouse-actions I most commonly use (I am leaving out a bunch of equally useful keystrokes, for a full list check out this page):

    • Spacebar: auto-completing search dialog (useful!)
    • Ctrl-z: undo (very useful!)
    • Shift-Ctrl-z: redo
    • Esc: cancel transformation, halt render (useful!)

    • Right Mouse Button (3D View): select/drag an object
    • Left Mouse Button (3D View): reposition the 3D Cursor
    • Mouse Wheel (3D View): zoom the view in and out
    • Shift + Hold Middle Mouse Button (3D View): move the view around
    • Hold Left Mouse Button + Hold Middle Mouse Button (3D View): rotate the view
    • Keypad 0 (3D View): toggle camera perspective

    • n (3D View): toggle the Properties side menu
    • g (3D View): move selected object(s)
    • r (3D View): rotate selected object(s)
    • s (3D View): scale selected object(s)
    • x (3D View): perform transformation along the x-axis
    • y (3D View): perform transformation along the y-axis
    • z (3D View): perform transformation along the z-axis
    • i (3D View): insert keyframe

    • F12: render scene as single frame
    • Ctrl-F12: render scene as animation

    These keystrokes let us manipulate our view of the “3D scene” and also allow us to transform our objects. For example, if we wanted to rotate an object along the y-axis, we would first select it, press “r” for rotation, press “y” to restrict the rotation to the y-axis, move the mouse to perform the transformation, and click the left mouse button to commit the transformation. If we want to cancel a transformation while testing it out without committing it, press the Escape key and the selected object will reset.

    About The Window Configuration

    Blender provides many different options for configuring your workspace. If you want to switch from seeing the 3D-view to seeing the UV/Image editor, you go to the current editor box in the window you would like to change (usually in the top or bottom left hand corner of that window) and select the UV editor option. There are 17 or so different editors you can choose to display. In addition to selecting which editor you want to use, you can specify where and at what size you wish to use it. If you place your mouse over the edge of a window you can drag to resize it. You can also create/destroy windows by right-clicking on the borders of windows and selecting either “split” (to create a new window) or “join” (to join two windows together). To cancel a split or join operation, press the Esc key.

    For this tutorial, we will be using mostly the default window-layout, so no rearrangement of the windows is necessary (although if you want to change things around, go for it).

    Getting Started

    Since we’re going to be frequently dealing with the location, rotation, and scale of objects, the first thing to do is open up the Properties sidebar by navigating inside the 3D-view window menu to View-> Properties (or use the shortcut, N).

    This will display a window that contains info about the currently selected object’s location, rotation, scale, and dimensions, as well as the location of the 3D cursor, which you can use to move and create objects to precise coordinates. Next we are going to delete the cube, so make sure it is selected (it should have an orange outline, if it doesn’t then right click the cube to select it), press the delete button on your keyboard, and confirm the deletion in the popup dialog.

    Now we can add a flat plane which we will later use to display a stars texture in the background of the Earth. There are a few different ways to add objects. We’ll be using the space-bar search dialog approach: press the Space Bar to display the search dialog, and type “add plane”. You’ll see that “Add Plane” is highlighted in blue in the search results.

    Press enter and you should see that a plane has been added to the location of the 3D cursor.

    Compositing

    The reason we just added a plane is because we are about to do 3D compositing, which means making a single combined (composite) final output based on multiple elements positioned in the 3D coordinate plane. The plane is going to serve as our background, which we will position the farthest away from the camera (which is the perspective from which our image/video renders are made), and the sphere we are going to add will be the Earth, which will be positioned closest to the camera. There are multiple ways of doing different kinds of compositing in Blender, so this method is not the only way of doing things (but it works fine for what we want to accomplish). I learned most of what I know about compositing, including this technique, from an excellent Blender text-book written by Roger Wickes called “Foundation Blender Compositing”. It’s a little old for today’s versions of Blender (I think the book was written using Blender 2.4.x ) but the principles behind the processes described in the book still apply.

    Setting up the Background

    There are a few things we need to consider when setting up the background, including the aspect ratio we want the final output to be in and the position of the plane relative to the other objects in the scene. We want the final output to have a 16:9 aspect ratio, which is the default. If we wanted the output to be in the 4:3 aspect ratio, we could change that by going into the Properties editor, navigating to the Dimensions section, and changing X to 4 and Y to 3 in the Aspect Ratio subsection.

    Since we want the background to be a plane, we need to make the plane a certain size so that it will fill the camera’s viewport. The default square plane would not fill to the edges of a 16:9 image if it were scaled to fit within the upper and lower bounds of the camera viewport, so we will change the plane’s dimensions and scale. Select the plane, and in the Properties sidebar under the Scale section type 9.0 for X and 16.0 for Y. The plane should now be a pretty large rectangle.

    Now we are going to scale the plane down. With the plane selected, press S (“Scale”) and move the mouse toward the origin of the plane to scale it down.

    Let’s move the plane backwards by adjusting its X-axis position. Press G (“Grab”) followed by X (“along the X-axis”) and move the plane a few grid sections away from the center of the 3D scene.

    Next, we can setup the camera. Select the camera, and in the Properties sidebar set the X, Y, and Z fields of the Location and Rotation sections to 0.

    The camera should now be in the center of the 3D scene. Since we want the camera to face the plane in order for the plane to be visible in our renders, set the camera’s X and Z rotation to 90 degrees.

    Now we can use the camera’s point of view to see if our objects in front of the camera are appearing how we want them to for the renders. In the 3D view’s menu, navigate to View-> Camera in order to use the camera’s viewpoint.

    The display in the 3D view now changes to show what the camera “sees”. If you have the camera still selected, you will see its orange rectangular outline. The area inside this rectangle is the part of the 3D scene that will be visible in the render.

    Our plane is currently too small to fill the camera viewport, so select the plane, press S and use the mouse to scale it up so that the plane matches the size of the camera. To fine-tune the size of the plane, you can zoom in to make sure that the edges of the plane and camera line up exactly.

    Awesome, now whatever texture we decide to put on our plane will completely fill the dimensions of our render. :thumbsup: Let’s add a sphere to represent Earth. In Blender there are a few different sphere types; we are going to use an Ico Sphere (the “Ico” comes from the name of the Icosahedron shape). With your 3D cursor still at the middle of the 3D scene (if you moved it, you can send it back to the middle by setting the X, Y, and Z fields of the 3D Cursor Location to 0 in the Properties sidebar), push space bar to bring up the search dialog, type “sphere”, and click on “Add Ico Sphere”.

    The sphere that gets added might be pretty large.

    So scale it down to size by making sure the sphere is selected, pressing S, and using the mouse.

    The default ico sphere is a good start, but it is not as smooth as we would like it to look. Select the sphere, and in the Tool Shelf (which should be on the left side of the 3D View, but you can check by navigating in the 3D view menu to View-> Tool Shelf) under the Shading section, press “Smooth”. The sphere should now look considerably smoother. We are also going to use an additional method to help get our sphere as smooth as we want it to appear. Inside the Properties editor (on the far right hand side of the screen), navigate to the Object Modifiers tab (represented by a blue wrench icon), click on Add Modifier, and select the Subdivision Surface (“subsurf”) option.

    Enabling the subdivision surface option will divide the polygons of the ico sphere mesh into smaller pieces, increasing the density of polygons and reducing the prominence of the polygon edges. In the Subsurf section under “subdivisions” you can see that subsurf is applied by a factor of 1 in the current View, but that a factor of 2 will be applied during renders. This is because calculating subsurf can be CPU intensive, so doing setting two different subsurf amounts allows us to have a preview subsurf that does not take long to render while se are working on the 3D scene and an actual subsurf when we set aside time for the render.

    Rendering

    So far, we have been working in the 3D view, which shows us a very basic version of what our final composition will look like. Similar to how the subsurf modifier has two different settings for the view and the render, Blender will show the user a non CPU-intensive preview of the 3D scene while they are working, but will maximize the computer’s processing power during the rendering phase to calculate exactly how the 3D scene looks. If we tried to render the 3D scene exactly as it was supposed to look while we were working on it, the lag would be so bad that we would not be able to get any work done (at least that’s the case on computers of mere mortals, like mine). But from time to time we want to see what the final result is going to look like, so we can utilize the Render tab (represented by a camera icon) of the Properties editor to prepare and execute our renders. At the top of the Render tab, there is a section (also called Render) that has three buttons: Render, Animation, and Play. The Render button will render the current frame of the current scene, while the Animation button will render all of the frames of the current scene (as determined in the Timeline editor, we will go over how to create a basic animation towards the end of the tutorial).

    Click the render button (or use the corresponding keyboard shortcut F12).

    This generates one frame of the final result. Notice the section below Render called Dimensions. In the Dimensions section, you can set the render Resolution, frame range of Animation renders, frame rate, aspect ratio, and a few other options we won’t worry about for now. So if you want your final output to be 1920 x 1080 pixels but don’t need to see the renders at full resolution each time, you can set the percentage underneath the X and Y fields of the Resolution section to something like 50% or 25% (which will set the renders to be generated at 50% and 25% respectively of the size 1920 x 1080, or whatever you set to be X and Y). To exit out of the render viewer and return to the 3D view, press the Escape key.

    Adding textures: the Stars

    Since we have our plane and sphere objects set up for compositing, let’s add textures to them both. The process may be a little confusing for beginners, we will go through each part step by step. The textures we will be using are both sourced from NASA: for the Earth texture we are using this resource and for the stars texture we are using this resource. Select the plane, and in the Properties editor window click on the Material tab (represented by a sphere-with-an-hourglass-ish icon) and click on the “New” button.

    This will add a Material to the plane object. You’ll see that a whole new section appears in the Material tab when you create a new material.

    For now, we will keep the default settings in the Material options as they are. Adding a Material lets us have the ability to add a Texture, which is how we will be applying the stars image to the plane. In the Properties editor next to the Material Tab, click on the Texture tab (represented by a checkerboard icon). This will display a list of empty texture slots which you can save different textures to. Click the New button to create a new texture.

    Similar to how creating a new Material works, when you create a new Texture you are provided many different options for altering how the texture will appear on the object you have applied the texture to. So our plane now has a blank Texture on a blank Material. To add an image as a texture, we have to set the Type of the Texture to be an image, so in the Type drop-down (beneath the list of textures), select “Image or Movie”. Doing this will cause a new section called Image to appear. In this section, click Open to add an image file.

    The view will shift to the file browser. Navigate to the directory (folder) where your image textures are, and select the image file of the stars. :star:

    Now we should see the image file we picked being displayed in the preview box of the Texture options. Scroll down a bit and expand the section labeled Image Mapping. This adjusts how the image will be fit into the space of the plane. Set the Extension drop-down to Clip, which will display the image on the plane according to the image’s original scale.

    Beneath the Image Mapping section there is a section called Mapping. The options in this section deal with how the whole texture in general is mapped to the object. Since our plane is flat, change the Projection drop-down to Flat. Above that, set the Coordinates drop-down to Generated. This will map the image to the coordinates generated by the plane. Now we should be able to render the scene and see our stars texture on the Plane. Render the scene by either clicking on the Render button in the Render tab of the Properties editor or press F12.

    Cool beans [insert bean emoji here]. Except there is a slight problem: in our original image of the stars (if you are using the NASA sourced image ), the reference code of the image “ISS006E40544” displays on the bottom, but the reference code in our render is displaying on the left edge. To fix this, all that we have to do is rotate our plane around / resize it until the image appears as we want it to (in this case, with the reference code on the bottom edge). Exit out of the render view, select the plane, and set the X and Z rotation to both -90 degrees and the Y rotation to 0 degrees (this can be accomplished in the Properties sidebar).

    Since rotating the plane messed up its alignment with the camera, let’s swap the X and Y dimensions of the plane to make it fit into the camera viewport again. Switch the values for the X and Y fields in the Dimensions section of the Properties sidebar.

    The plane should now fit inside the camera viewport again. Render the scene.

    Now the reference code displays on the top! But now to get the reference code on the bottom, all we have to do is perform a 180 degree rotation along the Y-axis. In the Rotation section of the Properties sidebar, set the Y field to 180 or -180 degrees.

    Let’s render the scene again.

    Finally, the reference code is displaying on the bottom edge, just like in the original image. In our finished renders we will want to hide the reference code on the plane so that only the stars are visible, but for now things look good enough that we can move onto setting the texture for the Sphere.

    Adding Textures: the Earth

    The initial process for setting up the texture on the sphere is exactly the same as it was for the plane. Only once we have the image loaded into the sphere’s Texture will we need to change certain options to account for the difference in shapes. Select the sphere, click on the Material tab in the Properties editor window, and click on the New button to add a new Material.

    This will set up the default Material options for our new Material.

    In our previous render, we noticed that the Earth was casting a shadow on the background, so in order to turn this behavior off, scroll down and expand the Shadows section, and make sure that the Cast option is unchecked.

    Render the scene again. Now the Earth does not cast a shadow on the background!

    Now let’s add the Earth texture by clicking on the Texture tab in the Properties editor window and clicking on the New button.

    This sets up a default texture for the sphere’s Material. Change the Texture Type to “Image or Movie” in the Type drop-down, then in the Image section click the Open button to load an image.

    In the file editor, select the image of the Earth texture.

    The preview section should then display the image you selected.

    Scroll down to the Image Mapping section and change the Extension drop-down to Clip. If during the tutorial you see a white seam appear on the Earth (where the left and right edges of the Earth image texture meet) while viewing renders, you can fix this by changing the Extension drop-down to Extend.

    In the Mapping section, change the Projection drop-down to Sphere and the Coordinates drop-down to Generated.

    Now let’s render our 3D scene again:

    The Earth texture should appear on the sphere. Yay! Now that we have added the two textures successfully, we can go about refining our 3D scene so that it looks more realistic.

    Refining the Composition

    Looking at the image, there are a few things that don’t look good. One is the interaction that the lamp is having with the plane and sphere, making the sphere look “shiny”. Another issue is the low brightness of both textures. The reference code on the stars plane is still showing, and the Earth doesn’t look as smooth as it could. Let’s take care of the lighting issues first.

    Select the Plane, click on the Material tab in the Properties editor window, and under the Shading section enable the Shadeless checkbox. This will make the plane independent from the effects of the light source in our 3D scene.

    Render the scene again, and now the stars should be displaying at the same brightness/contrast as they do in the original image.

    Now select the sphere and navigate to the Material tab in the Properties editor window. In the Specular section, change the Intensity slider to 0. This will remove the “shiny” :sparkles: effect from the sphere.

    Render the scene again. The Earth still looks dark, but no longer shiny.

    We’re going to change the lighting of the 3D scene so that the Earth looks bright but still has a shadowy edge. Exit out of the render view and change out of the Camera view by either navigating to View-> Camera in the 3D View window menu or by pressing 0 on the numpad. Select the Lamp and in the Properties editor window, click on the Object Data tab (represented by the sun icon).

    Now move the sun to the center of the 3D scene by changing its X, Y, and Z location in the Properties sidebar to 0.

    Move the sun away from the Sphere along the X-axis by pressing g followed by x and using the mouse to select a position. In the Object data tab under the Lamp section, change the type of Lamp from Point to Sun.

    The lamp will change to show a dashed line indicating the direction its light is pointing in.

    To set the shadowy edge of the Earth to a particular side, we can adjust the position and rotation of the sun lamp. To make the sun point towards the Earth, set the Y Rotation of the sun to 90 degrees in the Properties sidebar and press r followed by z to rotate the sun so that it is directed towards the sphere.

    Render the scene again, and now the lighting on the Earth should look much better.

    The Earth texture is still a little dark, so we are going to increase the intensity of the sun lamp. In the Lamp section of the Object data tab in the Properties editor window, set the Energy slider to 2.5.

    Render the scene again. The Earth’s land and ocean parts should appear relatively clearly now, and there should be a shadowy edge depending on where the lamp was positioned.

    Finally, let’s get rid of the reference code in the stars image texture. The proper way to do this would be to use an external image editor to remove the reference code and then load the corrected image back into Blender, but we are going to use a quicker method that demonstrates the power of being able to create composite images in 3D (and mostly since the background is just a bunch of stars that do not need to be represented precisely, at least in this tutorial :wink: ). Select the plane and either: scale it slightly upwards or move it slightly towards the sphere. Doing this will move the reference code portion of the stars texture plane out of the camera viewport.

    If we render the image again, the reference code should not appear.

    Sweet, we have the stars and the Earth looking pretty good! Before we call it a day, let’s look at how to fine-tune the display of our renders even further.

    Fine-Tuning the Render

    If you have been rendering the 3D scene at the default render dimensions (50% of 1920 x 1080 pixels), you will see that the Earth looks good, but it’s a bit pixelated. If you scroll in on the render result window, you’ll see that up-close it looks really pixelated.

    Now let’s set the render resolution percentage to 100% and re-render the 3D scene.

    That looks much better. But we don’t necessarily have to stop at that resolution, because the Earth texture that NASA provides can be downloaded at a pretty huge size (the one I’m using is 10800 x 5400 pixels). This means that we can increase our render resolution to approach the maximum size of the texture we are rendering. Doubling the resolution to 3840 x 2160 pixels results in an even sharper Earth.

    And doubling it again to 7680 x 4320 pixels looks spectacular.

    Although our Earth looks mostly smooth, there are sill polygon edges visible, like at the edge of the Earth in the upper right hand corner of the previous example render. To fix this, we can select the sphere, go to the Modifiers tab in the Properties editor window, and increase the amount of subsurf subdivisions applied in the render.

    With the additional amount of subsurf applied, the polygon edges of the sphere look much less visible. We could keep increasing the amount of subsurf until we had an amazingly smooth sphere, but the tradeoff is increased render time due to the CPU intensive nature of calculating subsurf.

    Here is the finished composite image. Note the amount of time it took to render a single frame at 7680 x 4320 pixels (the amount of time it took appears in the upper left hand corner of the render result): 6 minutes and 55 seconds! This may seem obvious, but bigger and better quality renders on the same machine require more time to finish. If you made it this far, give yourself a pat on the back. :clap:

    To save your render, navigate to Image-> Save As Image in the render result window. This will display the file browser where you can select a location to save the render image.

    Rendering an Animation

    The last thing we will do is make a short animation of the Earth rotating. To set the timing of events of our objects we want to animate, we set keyframes at particular frames to determine the duration of animation events. To do this, we will be working in the Timeline editor, which displays by default at the very bottom of the screen, below the 3D view. In the Timeline, the vertical green line represents the current frame that is being shown in the 3D View, which is also the frame that will be rendered during single-frame renders. You can set the starting frame and ending frame as well, but we are going to stick with the default animation length of 240 frames. With the sphere selected and frame 1 set as the current frame, press i to display the Insert Keyframe Menu. There are many options in this menu pertaining to recording the state of an object’s location, rotation, scale, or combination of the three, so since we are only rotating the sphere we will select the Rotation option.

    This will set a keyframe at frame 1, represented in the Timeline as a vertical yellow line. Now set the current frame to 240 (or the end of the animation), rotate the sphere 360 degrees along the Z axis, and then insert another Rotation keyframe.

    We have set the animation up so that the sphere will perform a perfect 360 degree rotation. Let’s examine a visualization of the animation “curve” by changing the Properties editor window type to the Graph editor. This will display a list of object drop-downs that have animations applied to them, and also shows a graph of the animation curves corresponding to the X, Y, and Z parameters of different animation events throughout the range of the animation. Since we only inserted Rotation keyframes, Rotation curves are the only ones that will be visible, and since we only altered the Z-axis, that is the only curve that will show any changes.

    Since we are only dealing with Z-axis rotation, we can delete the X and Y rotation curves. Expand the Rotation drop-down in the list section to the left of the graph, left click on the X and Y Euler Rotation entries, and press the Delete key to delete them.

    Notice the Z-axis curve is curved at both ends. This means that the animation will speed up / slow down near the the beginning / end of the animation. But since we want the Earth to rotate at a constant speed, we can change the type of curve to make it a straight line (rotating constantly). In the menu of the Graph editor window, navigate to Key-> Interpolation Mode -> Linear.

    This will make the curve linear.

    Almost done! All we have left to do is set some render options specifically for our animation. Change the Graph Editor window back to the Properties editor window and go into the Render tab. If you want your animation to finish quicker, I recommend setting you render resolution to something relatively small, like 25% of 1920 x 1080 pixels. Next, scroll down to the Output section. The animation will be saved to whatever path you specify in the field that displays the folder on the right. By default, Blender will save your animation to the tmp folder (located at the root of your system), although you can change this to wherever you want by either typing a new path or clicking on the folder icon and navigating to a location in the file browser. You can also specify a name for the animation file by typing the name you want at the end of the directory path. In the File format drop-down (where PNG is displayed as the default format), select H.264 under the list of Movie options.

    A new section called Encoding should appear. In the Encoding section, change the Format drop-down to MPEG-4. This will render the animation into a file-type that plays nice with a variety of computers/video players/ and editors (including the iPhone). You can leave the other options as they are in this section.

    We can finally render our 3D scene as an animation. Scroll back up to the top, and in the Render section click the Animation button.

    Once the rendering finishes (if you do not want to finish rendering the entire animation, you can cancel the remaining unrendered portion by pressing the Escape key during the render), navigate to the directory where the file was saved. It should play like any other normal MP4 file.

    Wrapping Up

    Now we are completely done! If you stuck with the tutorial this far, you are a true champ. :muscle: Seriously. Blender is not easy, especially for beginners, so doing something relatively easy like modeling the Earth is a big accomplishment. For the purposes of introducing Blender, the way we created Earth was fine. However, if we wanted to do a more hard-core and accurate rendering of Earth, we would need to address some issues with our current approach that negatively impact the realism of the final result, such as:

    • Currently the Earth is the center of our 3D universe
    • We positioned the Sun around the Earth, rather than the other way around
    • The stars texture is not accurate
    • The Earth is lacking an atmosphere and weather conditions
    • The lighting and shading of our Earth needs to better reflect how the actual (in space) Earth to Sun positioning acts
    • The Earth texture is flat and does not reflect subtle differences in elevation (such as mountain ranges)

    All of these things we will explore in depth in the next tutorial. The Earth we render in that tutorial will completely blow this Earth out of the water!

    Once again, if you made it this far, thanks and have fun Blendering. Stay tuned for the Advanced Earth tutorial, coming soon.

    Link to project files (.blend and image files used in this tutorial)