Big Planet Keep on Rolling

Same planet, slightly better render...

Same planet, slightly better render…

My intended post for last week took so long that I decided to simplify things a bit. I was going to discuss prettifying the tectonics.js output and making a blender animation of the prettified planet spinning. I’ve learned a lot about qgis(and wilbur) while trying to do this, but I’m still groping around. I’m not saying anything against tectonics.js, it’s my fault for pretty much ignoring too many of the useful hints the program gives and misinterpreting too many of the others. I also habitually underestimate just how wide my mountain ranges are. Anyway, for nor now I’m just going to focus on the animation using the planet I have. Not Earth, that’s just cheating, but I’m using the not altogether successful planet I tried to create over the last two weeks. I need a quicker workflow; one that doesn’t involve constantly googling for instructions…

I’ll start with a sphere similar to the one I put together for an earlier article on displaying your world. I replaced the bedrock color I previously used for the diffuse and specular color with a hypsometric texture I created in wilbur. My original intent was to create a more realistic satellite view with a simple climate model. That would have been awesome!

I used a 16-bit tiff image for the bumpmap. Sixteen bit png’s seem to fail in blender, so I used qgis to convert my png to tiff. I also wanted to create a subtle displacement map as well, but the sixteen bit tiff inflated the planet into a lumpy mess several times as large as the undisplaced sphere even with a nearly zero displacement influence. I decided to use a more conventional 8 bit  version of the map for a separate displacement texture.

First thing I tried was to use the gdal translate tool to convert my 32 bit floating point BT elevation map into an 8 bit png.

gdal_translate -ot Byte -of PNG ${input_file} ${output_file}
, where ${input_file} is the name and path to the input file…
,and ${output_file} is the desired name and location for the converted file.

Unfortunately, this failed badly. Basically, all the elevations were clipped to below 255 meters. Instead, I used the Raster Calculator to make an intermediate file with the following expression.
${input_elevation_layer} / 32.0
This will result in another 32 bit elevation file with values in the range of 0..255. It helped that I started with an elevation range from sea level to less than 8000 meters. The divisor may need to be larger if the range of values is larger and can be smaller for a smaller if the range is smaller. I then used the gdal function to convert that into an 8 bit png.

Since all I wanted was a very small relief like that on some globes, the 8 bit was sufficient. Unless you’re using something like terragen, there’s really no way to make a displacement map in realistic proportions, real planets are smoother than cue balls in proportion.

For the bumpmap I had used a normal influence of 12.0, for the relief texture, I used a displacement influence of point twelve. Even with values less than 256.

I decided to discard the clouds and atmospheric effects. Maybe this is a desk globe. Perhaps I should also model a stand for the thing… A slightly less subtle displacement might be in order.

Now that we have a kinda decent globe, let’s animate the thing. I started at frame zero, with the rotation set to zero. In the “tool palette” to the left of the 3d view(toggle it on and off with the “t” key), I scrolled down to find the keyframes section, clicked “insert” and selected “Rotation.”

At the bottom of the Timeline editor there are three numeric entry fields. The first two are labelled “Start:,” and “End:.” Predictably, these denote the starting and ending frames of the animation. This will be useful later. To the left of these is another numeric field with the current frame number displayed. Click on this and enter a frame number for the next desired keyframe. I chose to put in keyframes every 65 frames, so 0, 65, 130, 195, and  260. At each keyframe, I went to the numeric palette to the right of the 3d view(toggled with the “n” key), near the top you’ll find “transformations,” I added 180° to the z-axis rotation with each keyframe. So 0, 180, 360, 540 and 720.

With that done, it was time to go to the Properties editor and select the Render tab. There are sections here controlling the display of renders, resolution, anti-aliasing and the like. I invite you to experiment with other sections, but for this I’ll focus on the Dimensions and Output sections. In Dimensions select the desired resolution and frame rate. I went with a 960 by 800 pixel image size and 16 frames per second. If you change the resolution you may need to (g)rab and (r)otate the camera to restore the composition of your scene. I’ll wait.

Below the X and Y resolution there is an additional percentage field. This allows you to create fast test renders without messing around with the camera every time. This is a pretty simple project, but when you are dealing with more complex scenes and longer render times, its nice to be able to take a quick look at what your scene looks like to the camera.

Under the Output section, first select an output path. Since I’m going to render all the frames separately and stitch them together later, I decide to create a directory specifically for my render. Check overwrite and file extensions, you may need to redo things…

Below the Placeholders checkbox, which I leave unchecked there is an output format menu with a number of image and movie formats. You could choose a movie format like mov, avi or MPEG, but I’m going with png for individual numbered frames. I’m pretty sure you can give a C printf-style name template, but I’m not entirely sure.

To render an image press F12, to render an animation sequence, press ctrl-F12. You can also select them under Render in the Info panel menu.

Initially, I set the animation to start at frame 1, the frame after the initial keyframe and to end at frame 260, the last keyframe which returns the globe to its initial rotation. This is supposed to allow looping without hesitation, but when I rendered an avi internally, it seemed like the animation was accelerating up to speed and decelerating at the end. I’m not sure why this was happening, but the render time was a bit long, so I figured I’d render out a full rotation from the middle of the sequence and stitch images together in an outside program. Thus, I set start to 66 and end to 195. Once all the images were rendered and saved under names of the form 0066.png .. 0195.png, it was time for stitching.

From my understanding ffmpeg is the best free standalone program for stitching together images into movies(and a lot of other movie-related tasks; it’s kind of the image magick of movies).

In my unix terminal I enter the following command:
ffmpeg -r 16 -vsync 1 -f image2 -start_number 0066 -i %04d.png -vcodec copy -qscale 5

-r 16 sets the speed to 16 frames per second

-f image2 tells it to accept a sequence of images as input.

-start_number 0066 is important. It tells the program to start rendering from an image with frame number 66. Otherwise, if it doesn’t find an image with an index less than five it will assume files are missing and punt out.

-i %04d.png is a format descriptor telling ffmpeg where to look for input files. is the name and format of the desired output movie file.

The rest of the options may or may not matter. I’m not taking chances…

Next time, maybe I’ll add sound…

Comments, questions, corrections or suggestions are welcome! Thank you for your patience,
The Astrographer

This entry was posted in Mapping, World Building and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s