Blender 2.5 Exporting Height Maps Tutorial – Part 2

You can slide the node around to suite yourself and your window size. Also I have placed the needed nodes inside the green outline.

Next we need to convert the Z-vales coming from the render into a height map. To do that we need a Vector -> Map Values node. Click Add in the Node Editor window’s menu and add it. You can see how I have it positioned (B).

In the Render Layer node (A) click and drag from the Z output to the Value input in the Map Value node (B). This will connect the two with a Noodle.

My Terrain Work Screen for Height Maps

You can see I have connected another Viewer node to the output of (B). I use it to tell when I have the Map Values setting about right. That is its only purpose and it is not required.

I have the Map Values settings at -158-Offset and 0.01-Size. Depending on how far your camera is from the terrain these numbers will change. Rather than figure out how to calculate the value needed, just click and drag the Offset value left and right until you see the Viewer image change from black to white or vice versa. You want the Offset value as close to the change point as possible. For now just get close.

You want to be able to see some of the terrain features in the Viewer node. At some point you need to play with Offset and Size to get all the features showing. I just click until I get it.

Height Maps via Blender Nodes

To limit the output to Black and White I used a Color Ramp (C). Add -> Convertor -> Color Ramp. Connect the output from the Map Values (B) to the Fac input on the Color Ramp (C). I left the colors B&W and in the black to white order. Since the color for a height map is reversed, they need to be reversed. That is more clicks than just adding a Color -> Invert (D) node.

Connect the Image output of the Color Ramp to the Invert node’s Color input. You can see I added another Viewer node.

Now I added an Output -> Composite (E) and Viewer nodes (F) to the Invert’s output. That completes the process setup. This last Viewer Node (F) at the far right is needed… I think. At least it is handy.

Now look in the Render Layers (A) node and notice the small camera icon in its lower right corner. That is a render button. It can save you a load of time. Click it and you should see Blender render the height map image. You may not see all the detail you want. So, now it is time to tweak the Map Values settings. Mess with them until your high point is white and your low point is black.

The black does not have to be perfect nor does the white. Also, you will probably get more detail in OpenSim than you may see in the image. So, don’t fuss too much until you have some experience to guide you.

The Export

Once the image renders you will see it in the UV/Image Editor and the Camera Window. The Composite Viewer (E) places the image in the camera window. You can select Image -> Save as Image to export the image to a file for import to OpenSim or SL. You can do the same in the UV/Image Editor window. Either is OK.

In the Blender 2.59 select the file type selection is done in the lower right of the file directory window. I think PNG works best.

The OpenSim Import

You did backup your region?

In the OpenSim console use: terrain load [path\filename] to load the terrain. If you have a viewer open and are in the region you can watch the update happen, which is kinda fun.

Chances are things will not be right. Check your ocean floors to make sure they match with adjoining regions. Use terrain elevate to raise the terrain and terrain lower to lower it to match them. Type a numeric value of how much to raise or lower.

If you are matching to existing terrain or buildings you may need to do some scaling. You use terrain multiply and a value to do that. Using terrain multiply 0 sets the terrain flat at 0 elevation. Using 1 is no change. Using a value of 2, doubles the height. To stretch the terrain up 2% use 1.02. To shrink it 2% use 0.98. Each time you use 0.98 it shrinks the changed terrain another 2%. Doing it 3 times produces a total shrink of 5.88%. Using 1.02 three times produces a 6.12% increase…

Tweak until you have it right.

If you are making new terrains, you get to avoid all the tweaking. Lucky you.

Summing Up

There are other ways to accomplish the same thing in Blender. Once this file is setup it is the easiest to use. Or so I think. Just delete a terrain and make a new one. Press render and you have a new height map. No materials to assign. No lighting. No dealing with map input problems. A UV Map is not needed.

In all it is pretty simple.




2 thoughts on “Blender 2.5 Exporting Height Maps Tutorial – Part 2

  1. If you are looking for a full range heightmap, I would suggest replacing the Map Value node with a Normalize node. This way you won’t need to mess around with offset and size, which inevitably will give you a lower quality height map. Hope this helps!

    Best Regards,

Leave a Reply

Your email address will not be published. Required fields are marked *