Painting Planets Using Blender’s Texture Paint Tool

I’ve been interested for awhile in using the Texture Paint tool from Blender to paint on the globe. There are a few things that you need to know how to do to make this technique work. First, you need a uv-mapped sphere. This can be done in a variety of methods, but I still find the icomap method I’ve used before to be the most reliable and effective. The uv-map image texture doesn’t necessarily have to fit any particular projection if you’re going

The Tissot Indicatrix of an icomap. Each of the "circles" on the map represents a true circle on the spherical surface, all of the same size.

The Tissot Indicatrix of an icomap. Each of the “circles” on the map represents a true circle on the spherical surface, all of the same size.

to use the POV-Ray spherical camera to reproject the globe, but it is best to have a mapping with a minimum of distortion of shape and area. This allows each pixel to reliably represent roughly the same surface area  with a minimum of distortion. The icomap projection does a very good job of this as shown by the Tissot indicatrix.

The fact that all those little “circles” have nearly the same area and are close to circular is a good indicator that distortion is minimal over nearly all of the surface. Although equirectangular projection(also referred to as “spherical,” “latlong,” “geographical,” “rectangular,” or “plate carée”) is a good universal interchange format, it is very distorted it’s miserable to create an appropriate uv map, which is required for the Texture Paint tool, so essentially I’ll paint to an icomap and use POV-Ray to convert that into an equirectangular.

I’ve been wanting to do a video tutorial for awhile. Mainly ’cause I’m not sure how clearly I’m describing the things I’m doing. Unfortunately, this being the first kind of ground up procedure, things got a little long. I’ve decided to split up the procedure into several separate sections. Along with each video, I’ve included a rough transcript. The video is good for showing where things are and roughly what is being done, but when you’ve got that out of the way and just want to refer back to find forgotten keystrokes and such text is much more efficacious.

NOTE: My limited talents as an actor, the learning curve of video editing software, and problems uploading to Youtube have all conspired to greatly delay this post. With that in mind, I have decided to post the text now and add in links to the videos as I can get them together. In the meantime, Andrew Price has tutorials for pretty much everything I know about Blender so far. If you dig into his tutorials and have a look at a few of the related videos on the Youtube sidebar, the text here should be pretty clear. My videos may even be anticlimactic. Oh well…

Part 1: Setting Up the Spherical Canvas

This video will demonstrate the process of creating and preparing the globe which will be the canvas on which the map will be painted.

Press shift-A to bring up the Add Object menu. Under Mesh, select Icosphere to create our globe.

The default Icosphere, as it turns out, is not a true icosahedron. It is a geodesic spherical shape consisting of triangular faces, but it’s not the classic d20 shape we all know and love. This is perfectly usable with the POV-Ray method for creating equirectangular maps, but I’d like to have a proper icomap straight out of the box. Just personal preference, that…

Hit the T-key with the mouse pointer in the 3D View space to bring up the Tools Panel, and at the bottom there will be a pane that allows editing of the parameters for the last command entered. The top entry for the Add Ico Sphere pane controls Subdivisions. Change it from the default setting of 2 to 1 to get a true icosahedron.

Now go into Edit Mode. Select Mesh>Faces>Shade Smooth in the 3D View footer menu or click the Smooth button under Shading in the Tools Pane. Hit the A-key deselect all faces and, making sure the select mode is set to Edges, select an edge at the north pole. Holding down shift, select the other four edges around the north pole and all five edges around the south pole. Now select an edge crossing the “waist” of the icosahedron. This is somewhat arbitrary, but if we want a particular orientation to our icomap, it pays to select the edge with care and take note of its direction.

Looking at the icomap generated by Flexify, we see that the edges on either side trend from northwest to southeast. The best edge to select, for that case would be the one that coincides with the positive Y-axis. The best way to find this edge is to look at the icosahedron in Object View. Later, this information will be used to select an appropriate look_at value for the POV-Ray camera. So make sure to write down your choice of direction.

Wilbur-generated icomaps have the opposite orientation, so the edge passing through the negative Y-axis would be appropriate.

Classic Traveller-style icomaps cut through the middle of a triangle. The best way to reproduce this effect would be to cut the triangle that the negative X-axis passes through using the knife tool. In the accompanying video, I demonstrate the Traveller style, both because it is the most challenging, and because it allows me to introduce a new and very useful tool, the knife. With the appropriate face and the north pole in view(the knife tool interferes with the view controls, a bit of a bug, frankly), hit the K key to use the knife. Click the vertex at the bottom of the triangle and, holding down the control key, select the midpoint of the upper edge. Click again on the north pole vertex and hit return to make the cut.

In the Shading/UVs tab of the Tools panel, under UVs, is, not surprisingly, the UV Mapping section. Below the Unwrap menu button click on the Mark Seam button. If you look at the 3D View canvas, you will see that the selected edges are highlighted in red to show that they are seams. Now, select all vertices of the icosahedron and click Unwrap. In the UV/Image editor, we will find that the unwrapped faces are displayed. In the UVs menu, check snap to pixels and constrain to image bounds. Using the Grab, Rotate, and Scale tools we will center the unwrapped faces and stretch them to almost fill the image space. “Almost,” because, even with large bleed, I had problems with blank spaces where edges were too close to the image boundaries. I’m hoping a bit of a margin will alleviate that.

Next, in the Properties View, give the icosahedron a basic material. Click the material tab, a coppery-colored ball with a faint checkerboard pattern. Under that tab, click the New button to create a new material. Don’t worry about the settings for now. It might be helpful to give the material a more informative name like “planet_surface” if you like. In the Options section of the material, make sure to check the UV Project box.

The last step in preparing the globe which will be the canvas for our map, will be adding a subdivision modifier. In the Properties view, select the tab with the wrench icon. This is the Object Modifiers tab. Under that tab, you will find a menu button which reads Add Modifier. Click on that and select Subdivision Surface under Generate. Under options, uncheck Subdivide UVs. Set Subdivisions in View to about 3 and in Render to about 4. If applied, 3 subdivisions will result in 960 faces and 4 subdivisions would result in about 3840. Keeping those face counts down could speed things up a lot down the line when painting.

Note that, while the particular way of marking seams for a Traveller-style icomap may be suitable for converting maps to equirectangular, the “sphere” that results is pretty badly distorted for display purposes. You can fix this with Spherize in Edit or Object mode(Shift-alt/option-S)!

Now on to Texture Paint!

Part 2: Painting the Texture

First off, in the main menu bar, open File>User Preferences… Look at the Add-Ons tab. Make sure Paint:Paint Palettes, Paint:Texture Paint Layer Manager and Import/Export:Wavefront OBJ format are all checked.

Set the 3D View to Texture Paint mode.

In the Tools panel(T-key), look under the Tools tab for the Color Palette section. This is probably an empty palette to start with. To add a color, click on the plus-icon next to Index and set the color in the usual manner. You can add a name for the color entry in the text field next to the color wheel icon. Repeat this process till you have your desired palette.

To save your new palette, start by clicking on the file folder icon at the bottom of the Color Palette section. This will allow you to select the directory from which to choose existing palettes or in which to save your new palette. At the top of the palette, there will be a pull-down menu saying Preset, find the plus-icon next to that and press it. Enter a name for your palette and press OK. The palette should be saved.

You’ll find the paintbrush settings in the Tools panel, at the top of the Tools tab. In this section, you can set the size and strength of your painting brush. Next to the radius and strength fields, there are buttons which allow control of the attributes by pen pressure. You can also set color here, but the palette will allow you to reliably repeat color selections.

Above the Color Palette section, you’ll find the Curve section. This allows you to set the softness of the edges and the sharpness of the center of the brush.

Finally, near the bottom of the Options tab of the Tools panel, you’ll find a Bleed option. A large bleed will make it less likely to render grey edges on the surface. Larger the safer. If you want to use the icomap you paint directly, it’s best to leave this at zero. Bleed also makes painting a bit slower…

The next point is the use of Texture Paint layers. Near the bottom of the numeric panel(N-key) are two sections of interest.

The first section is Texture Paint Layers. This allows you to select any materials associated with the object and, below that, any any existing textures that are part of the selected material. To edit any given texture, simply click on the paintbrush icon next to the texture’s name. If you don’t see any textures with paintbrush icons then you need to read the next paragraph.

Beneath Texture Paint Layers, you’ll find the Add Paint Layers section. If you don’t yet have a diffuse color texture, click on the Add Color button to add a new layer. Give it a name and you should find that texture listed in the Texture Paint Layers section above.

At this point just start painting on the globe.

Setting up a bump map layer can be a bit more complicated. While clicking Add Bump is simple, as far as I can tell it creates an 8-bit image. For bump maps, it’s best to use at least 16-bits to avoid stair-stepping. Also, part of the intent of this exercise is to create detailed map data down the line.

With that in mind, we’re still going to create the new bumpmap Texture by clicking Add Bump. Now we’re going to go into the UV/Image Editor View and, find the button with the plus sign next to the image browser pulldown. Click that, and in the window that pops up enter a name, a desired resolution. Make sure to check “32 bit Float” before you hit OK. In the Texture Properties make sure to select the 32 bit image you just made in the Image section, and in the Mapping section, make sure the Coordinates are set to UV and the Map your UVMap shows in the Map selection area. In the Influence section, make sure Normal, under Geometry is checked and everything else is unchecked. Make sure the normal influence is a positive value. I’d go with 1.0 while painting. You can adjust the value(probably downward)later, to make it pretty. Your canvas is now ready to paint in the bumps.

For best results, use one of the pointier brush Curves, fairly low Strength and Radius with pressure-sensitivity for both, and set the Blend to Add(to raise) or Subtract(to lower). For most purposes, leaving the color set to white is perfectly good. You should now be prepared to start painting bumps!

If your computer is decently fast you should use Textured viewport shading. I use a 5 year old bottom of the line MacBook, things get a little boggy, but it’s still usually worthwhile to be able to see what my bumpmapping looks like.

Once you’re done, save the color map to png and the bump map to 16 bit TIFF. I’d love to use full 32-bit OpenEXR, but my conversion paths are limited.

Part 3: Flattening to Equirectangular

In the main menu, select File>Export>Wavefront(.obj) to export the globe. Give it a name and save it.

Now open Wings3D. In the menu select File>Import>Wavefront(.obj)…, and find your saved globe object. Now, we’re going to turn right around and export to POV-Ray(File>Export>POV-Ray(.pov)). Wings3D is a capable and highly useful modeling tool, but this time all we’re doing is using it to translate between Blender and POV-Ray. Go figure…

Now we can go to our favorite text editor to change some settings in the generated .pov file. In global_settings, set ambient_light rgb vector to <0.7,0.7,0.7>. If this proves too dim after rendering, you can increase it later. Set camera_location equal to <0,0,0>. Comment out(//) right up angle and sky. Set camera look_at according to the location where you made the waist seam in the uv-mapping stage. Note that Y and Z are reversed in POV-Ray relative to Blender. So, if your cut was across the positive y-axis, you’ll want to look at the negative z-axis(<0,0,-1>). For the Traveller-style map, my cut was across the negative x-axis, so in my example, I’d set the look_at to <1,0,0>. Comment out light source(nest it between /* and */). Add the uv_mapping statement to texture. Go down to ambient, and comment out the color_rgbf statement. Add, image_map {png “name-of-map-image”}. You should be able to render now and save the image to disk.

Finally, we open the resulting image in Photoshop and flip the canvas Image>Image Rotation>Flip Canvas Horizontal. The analogous command in GIMP would be Image>Transform>Flip Horizontally. Save the result and you have your image as a proper equirectangular map.

Part 4: Converting the Bumpmap

To do the same for the bumpmap, you need to be able to convert the 32-bit image into something that POV-Ray can render to. You could possibly use Landserf to convert the 32-bit single-channel data into an RGBA separated png image, and project that in POV-Ray. Then come back to Landserf to recombine. You’ll would want to save the 32-bit bumpmap to OpenEXR in Blender, use Photoshop to save that to a 32-bit TIFF, then use GDAL to convert the TIFF to something Landserf can read(like BT ).

 

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s