Blender Relief Tutorial: The Plane

Previous Chapter: Blender Basics

As I mentioned earlier, Blender is like a virtual photography studio. We’ve got our camera, our light source, and the object we want to take pictures of. Let’s take each of these three pieces one at a time, starting with the last one: the thing we want to photograph. Our goal here is to generate a 3D model of our terrain within Blender, so that eventually, when we’ve positioned the light source and camera correctly, we can capture a relief image.

So, where does the terrain model come from? Well, we’re going to make a plane in Blender, then deform it according to our heightmap file (that greyscale terrain image), making some parts of the plane higher or lower based on what the heightmap says. First, though, we need to start with a clean slate. Get rid of all the various meshes you made (including the default cube), so that you’ve got a blank scene with just a camera and a light source. You can also just restart Blender and delete the default cube. Remember, you can delete an object by selecting it and hitting the Delete key. Hitting X also works.

Next up, let’s add in a plane mesh by hitting Shift-A and choosing Mesh → Plane. As before, it’ll appear wherever we last had our 3D cursor.

NewPlane.jpg

Let’s move the plane to the center of our coordinate grid (it’ll make lining things up easier later on). Select the plane, then go over to the Properties panel. This time, select the icon that looks like an orange(ish) cube; this will take you to the Object Properties. Among other things, you’ll see info on the XYZ coordinates of the plane under Location.

ObjectProps.jpg

You can change these numbers (and thus move the plane) by clicking in the center of each. If you click on the triangles on the sides of a number, you’ll end up incrementing/decrementing it. Change each number to zero, and watch the plane move to a more convenient location.

CenterPlane.jpg

While we’re here, there’s one other thing we want to change: the aspect ratio of the plane. I can stretch it in one direction or another by entering numbers in the X and Y fields of the Scale just to the right of the Location fields. We need the plane to match the aspect ratio of our heightmap. Right now it’s a square, and that’s really only good if we’ve got a square heightmap (which perhaps you do). The one I’m using in this tutorial, though, is 2000px wide and 2800px tall. I could plug in 2000 for the X and 2800 for the Y value of the Scale, but if I do that, the plane will become huge and fill the whole screen. Let’s do something more manageable and just plug in 2 for the X and 2.8 for the Y value. The actual numbers don’t matter much, just so long as their ratio matches the heightmap. Plug in whatever numbers work for your own heightmap if you’re using your own.

RescalePlane.jpg

Setting up a Material

Ok, so now we’ve got our plane in the right position and it’s the right size; it’s time for things to get really complicated. When I write tutorials, it’s important to me that I don’t just offer you a step-by-step list of “click here, type there.” I prefer to try give you an explanation as to why you’re doing these things. So, let’s take a moment learn a little more about 3D modeling.

In the real world, substances such as wood, stone, glass, etc. look different from each other because they have different colors, different surface textures, different roughnesses, etc. Blender is designed to simulate these variations by letting us assign different material properties to our objects. This is a big contributor to the realism of 3D models: the rendering engine calculates the scatter & bounce of light differently for different objects based on the properties they’ve been assigned. Each object in Blender is made of what the system calls a material. Materials are just collections of properties that tell Blender how light should interact with the object — basically, what sort of real-world substance the object should pretend to be made from.

As our next step, we need to assign a material to our plane, so that it’s made from something. Right now it’s not really made of anything, so the system is, by default, giving it a dull grey appearance. If you render the scene, you’ll see what I mean.

DullRender.jpg

Boooooring

To set up a new material, let’s start by looking at the plane’s Material Properties. Make sure your plane is selected, and then click on the little icon that looks sort of like a sphere with a checkerboard pattern on it, on the Properties panel.

Materials.jpg

Here, in Material Properties, we see that the plane has no material. It’s not really made from anything, and right now the only reason we can see it on our renders is because Blender has filled it in with some default material. Let’s change that by hitting the New button.

Blender creates a new material for you called “Material.001” or somesuch. You can call it whatever you’d like, if you want to put in a new name. In any case, some properties of this material should now appear in the window. For now we actually just want to keep the default settings here, but, again, I am strong believer in the “understand what’s going on” model of tutorial vs. the “click this and things will just work” model, so let’s have a quick look at what we’re seeing.

MaterialProps.jpg

The Surface option for the material says “Diffuse BSDF,” which is the name of a type of shader. We don’t really need to get into those much here (again, we’re just scratching the surface of what Blender can do), but basically it tells Blender how light should bounce of this object. If you click on that menu, you’ll notice there are lots of other shaders there. Glossy ones, glass ones, hair ones, etc. Each represents a different way for light to scatter off an object. Feel free to look at the different options, and open the Preview menu to have a look at how it changes things (or just keep re-rendering the scene). For making a shaded relief, let’s stick with the default Diffuse BSDF (that stands for bidirectional scattering distribution function, if you’re curious). We don’t need to make our shaded relief terrain out of glass or velvet (once we’re all done you can come back and give it a try: it’ll look interesting, but it generally won’t be very cartographically useful).

There’s also an option to change the Color of our plane here. For a shaded relief, the default light grey is good, though you’re welcome to play around with this and produce relief in other colors. I’m going to stick with grey. Later on you might want to come back and tweak the color a bit (to a lighter/darker grey, for example), but let’s leave it light grey for now.

Once you’ve had fun playing around with these settings, put them back to where you found them (Diffuse BSDF, light grey color).

Displacing the Plane

Blender materials don’t just describe an object’s color, or whether light should interact with it like it’s made from glossy paper or velvet. Materials can also have displacements — basically, bumps in the surface. And this is where we can turn our simple plane into a 3D terrain model: we’re going to tell Blender that we want our material to be bumpy, and those bumps are going to form the shape of our terrain.

On the bottom of the 3D view window, click the far left icon and switch to the Node Editor by choosing from the menu.

Node Editor.jpg

Now, if you’ve got your plane selected, and you’ve applied the material correctly, you should see something like this:

Nodes.jpg

This is a little diagram that shows how our material works. You can zoom and pan just like in the 3D view, if you’d like to adjust what you’re seeing. Right now it looks like we have a Diffuse BSDF shader with a light grey color. This is exactly where we left things in the Material Properties panel. This node is plugged into the Surface of our final Material Output, meaning it’s what’s being used to determine the plane’s surface color and its light-scattering properties. Notice that our material output also has an option for us to plug in something that will give the surface a Displacement. This is where we will add our bumpiness. From the bottom menu bar, choose Add → Texture → Image Texture. A new box will appear in our node editor.

AddImageTex.jpg

In Blender terms, a texture is an image or a simple pattern that gets applied to a material to change its appearance. We could use textures to change an object’s color, for example: I could load in a little photo of a wood grain and use it as a repeating texture to cause my plane to look like it’s made of wood. Maybe you’ve done stuff like this in Photoshop or other image editing programs before. But Blender can also use textures to bumpify (to use a John Nelson sort of word) our plane. So that’s what we’ll do.

We need to first load in our heightmap. Click the Open button in the Image Texture box. You’ll can then browse around until you find and select your heightmap. Once you’ve got it loaded in, you should see its name appear. You might want to click and drag on the edge of the Image Texture box in order to make it bigger.

LoadImageTex.jpg

Now, let’s plug this thing in. Click on the dot on the right side of the box that says Color and then drag over to the dot on the Material Output box that says Displacement. They’ll connect. We’ve now told Blender that it should look at the color (lightness or darkness in this case) of our heightmap and use that to determine where our plane’s bumps should be higher or lower.

Connected.jpg

A couple of other settings need to be tweaked here. First, click on Linear and change it to Smart. This changes the interpolation of the texture to be a little nicer-looking. Your heightmap may need to be resized/resampled a bit to fit the size of your final rendered image, and this just tells Blender how to do it. If you’ve used Photoshop or ArcMap to resample things, you’ve seen similar settings to these.

Next, where it says Repeat, choose Extend from the menu. This tells Blender that you don’t want your image to be a tiled, repeating pattern, but instead to stretch from edge to edge on the plane. If you don’t change this setting, your final image will actually look almost right (Blender isn’t going to shrink your image and tile it many many times), but the final relief will have weird shadows on the edges because Blender takes your image and tries to wrap it around the edge of the plane just a little bit. Basically, it’ll take a little sliver of the terrain from the bottom of the image and put it on the top, or from the right and put it on the left, etc. So a fragment of the mountains on the right side of your map would end up casting shadows on the left side, which is all wrong. Setting to Extend fixes this issue.

So now the settings should look like this:

Goodsettings.jpg

Now, if you render your image at this stage, you’ll be disappointed to see that nothing has changed. Where are those bumps we asked for?

DullRender

Still booooooring.

Turns out we still need to do a couple more things.

UV Unwrap

First off, we need to explain to Blender exactly where on our plane it should apply the heightmap texture.

As I mentioned above, Blender lets us apply simple 2D images to 3D objects. I could make a cube, for example, and then wrap it in a 2D image of stone, and end up with a cube that looked like it was made of stone. But before I could do that, however, I’d need to tell Blender exactly how to map the 2D image onto the 3D surface. This is all done via a system called UV mapping. Follow that link if you want to learn more. Meanwhile, I’ll give a really abbreviated explanation.

Below is a cube, and an “unwrapped” version of that cube. Imagine it’s made of paper and has been unfolded until it lays flat. Now that it’s flat, I can assign simple 2D coordinates to it (U and V coordinates), so that any part of the cube’s 3D surface can be match to a corresponding set of X and Y coordinates of an image texture.

UVUnwap.jpg

So, with UV mapping, we tell Blender where to line 2D textures up on 3D surfaces, by first flattening out those 3D surfaces into 2D versions of themselves. Hopefully that makes sense.

Of course, we’re not working with complex 3D objects here. We’ve got a plane, and it seems like the relationship between our flat plane and flat heightmap should be pretty obvious: we want the image to completely cover the plane. But, Blender doesn’t know that unless we tell it.

First, let’s go back to the 3D view. Click the far-left button on the bottom menu bar to once again bring up the editor selection menu. Then choose 3D View.

Backto3D.jpg

Select the plane, then hit Tab to go back into Edit Mode. Then, from the bottom menu, select Mesh → UV Unwrap → Reset. You probably won’t see anything happen, but it did.

Reset.jpg

Blender took a moment to analyze the object and determined that it has exactly one surface, and then assigned it UV coordinates. UV unwrapping is weirdly non-intuitive, and I am sorry to say I don’t quite understand why specifically hitting Reset gets it right, but it seems to. In any case, Blender now knows how to apply our texture to that single surface: every part of our heightmap texture has been assigned to a corresponding part of the plane.

You can now hit Tab to exit Edit Mode.

Subdivision Surface

Now there’s one more step we must take before we can start to see our terrain finally pop out.

As I mentioned before, we’re asking Blender to look at our heightmap and use it to apply bumps and valleys to our plane. However, our plane right now is far too simple for that to work. It’s made up of only four vertices.

Vertices.jpg

These vertices are the actual things which Blender moves up and down to make those bumps and variations in the terrain. So, right now, all that Blender could do is nudge the corners of our plane a bit. There are no vertices in the middle of the plane for it to adjust. Ideally, this plane would be made up of a sea of many thousands of vertices, each of which could be adjusted up and down to create the terrain.

Thousand.jpg

Lots of vertices for Blender to nudge up and down. Note that your plane will never look like this during the tutorial — I’ve used a different method just to illustrate things better.

So, let’s see about making our plane more detailed and complex. First, make sure it’s selected. Then, go back over to the Properties Panel and click on the blue wrench icon to bring up the Modifier Properties. From the dropdown, choose Add Modifier → Subdivision Surface.

Subsurf.jpg

The Subdivision Surface modifier (“subsurf,” as it is often called) tells Blender to increase the detail level of a simple object. This involves subdividing objects to add more vertices, and can also involve smoothing or rounding. Modelers use this tool heavily: it lets them make complex, curved shapes while only having to draw simple meshes.

Surfed.jpg

Simple meshes on the left. On the right, the same meshes with a subsurf modifier applied.

In our case, we’re going to simply use it to cut our plane up into a bunch of tiny pieces so that it has more vertices, which means we’ve got more places for our heightmap to make bumps.

First off, make sure Simple is selected. There are a couple of algorithms for subdividing things, and this is the one we want. The Catmull-Clark algorithm will make the edges of your plane start to round off, and we don’t want that.

Next, check the box for Adaptive. This tells Blender that, instead of dividing the plane up by a set amount, it should decide how much to divide the plane based on where more detail is needed. It will look at how big of a relief image you’re going to generate and how far away different areas are from the camera (once we eventually put it in the right spot, directly overhead), and then decide how much detail each part of the terrain needs. It’s pretty clever.

SettingsSubsurf.jpg

Though you may be tempted to, there is no need to click the Apply button. In fact, you shouldn’t. This subsurf modifier is a non-destructive filter; perhaps you’ve seen things like this in Illustrator, Photoshop, etc. It’s not actually changing the plane right now: it’s still really just made of four vertices. Instead, Blender will subdivide the plane up at render time, and then only temporarily. Hitting Apply will permanently subdivide the plane up into thousands of vertices. This will slow your computer down and make your saved file sizes much larger. It will also make rendering a little bit slower. And it won’t let Blender adaptively determine where more or less detail is needed. So, in sum, let’s leave it be. We’ll keep our plane very simple and easy to use, only temporarily making it complex when it’s time to do the render.

Speaking of renders, it’s time to have a look. Render the image and you should finally see your terrain!

ImprovedRender.png

The camera’s in the wrong position and the lighting is off, but we’ll get to that. The important thing is that we’ve now managed to turn our plane into a terrain model. Remember to hit Escape to return to the 3D view.

True Displacement

We need to change one last property before we’re done with the plane. With the plane selected, head back over to the Material Properties by clicking on that checkered sphere icon again.

MatPropIcon.jpg

At the very bottom of the panel, there are some Settings options. You may need to click on the word Settings to get them to appear. The Displacement option will be set to Bump. Change it to True, instead.

TrueSetting.jpg

With the default setting of Bump, Blender is (as the mouseover tooltip indicates) simulating the displacement. It’s using a quick, simple calculation to give an appearance of depth, but the bumps aren’t real: they don’t cast shadows, and light doesn’t bounce off them. It’s just some discolorations on the plane. Setting it to True actually deforms the plane. Have a look at the difference:

True.jpg

The resulting image, you’ll notice, has a lot more depth to it. Notice, for example, how the edges of the plane aren’t straight lines anymore. As the terrain becomes higher and lower, the edges go up and down. Before we changed this setting, Blender was just putting some light and dark areas on a flat surface to make it seem like it was bumpy. Now that we’ve fixed the setting, the terrain is actually bumpy.

So, let’s briefly recap our efforts up to this point:

  1. We made a plane mesh.
  2. We told Blender that the plane is composed of a grey material with a bumpy texture defined by our heightmap.
  3. We defined UV coordinates so that Blender could figure out where to put the texture on the plane.
  4. We told Blender to subdivide our plane into many, many pieces, so that it had lots of vertices to move up and down.
  5. We told Blender to quit faking the displacement and actually do it for real.

With that, we’re done messing around with the plane for a while, and it’s time to tend to other parts of our photography studio.

Next Chapter: The Camera

Advertisements