Blender 3D: Noob to Pro/Landscape Modeling II: Texture Stenciling

UPDATED FOR 2.7 USERS

edit

This is a continuation of the previous tutorial, Landscape Modeling I: Basic Terrain. In this tutorial, we will make our terrain look even better by using some texture stenciling to add multiple textures where we want them in the landscape. This tutorial assumes that you have a basic understanding of how to use Blender (how to add/remove a mesh, how to change views, etc...)

Creating the Stencil

edit

The landscape from the previous example looks pretty good, but the entire thing has the same texture, so it doesn't look very natural. Let's add some rocks to those hills. If we just add a second texture to our material, it will completely cover the previous one. What we want is to have the first texture only show in certain places and the second texture cover the rest. In order to do this we'll have to create a stencil, which is like a mask that determines where textures appear on the material. The stencil is a black and white image, similar to a heightmap, except the intensity of each pixel determines how much of the next texture will appear (black = 0%, white = 100%). I highly recommend viewing this tutorial for a more in depth description of how stencils work. If you think you have the gist, then continue on here. [Note: Link is broken now] We're going to create our own stencil to determine where we want rock in the landscape by "painting" on the object. *IMPORTANT* The next few steps will be performing temporary modifications to your scene, so be sure to save your file before you continue so that the changes will not be saved!! Also, if you have a subsurf modifier on the landscape, remove that at this time as it drastically slows down the following process.

  • Select the landscape object and switch from "edit mode" or "object mode" to "Vertex Paint mode". This is found in the Mode drop down menu, on the 3D View header. This mode lets you paint the object, and thereby change the color value of each vertex. When in Vertex Paint mode, you'll notice your object change color to a pixelated version of the texture that is applied to it. This is because with that texture applied, each vertex will be drawn with the colors you see.

Noob Note: Vertex Paint mode is in the drop down menu that contains Object mode and Edit mode. Just select the object while in Object mode, click the drop down menu, and select Vertex Paint mode from the list.

  • Switch to the Editing menu (F9) and you'll see a new tab called Paint. Notice the sliders labeled Opacity and Size. Opacity determines how much to blend the selected color with the existing colors when you paint. So 0.2 means that when you click, you'll get 20% of the selected color mixed with whatever is currently there. Over on the right are different options to combine to colors. We want to mix, so as we paint the colors will mix together and give us a nice smooth blend. Size is the size of your cursor while painting, and thus how many vertices are affected. Keep in mind that does not change as you zoom in and out, so a size of 10 can actually paint more pixels if you're zoomed way out than a size of 30 if you're zoomed way in.

 

  • Change the color to black and click the button that says Set VertCol (in 2.48 version, that button is below the color square and named 'SetVCol'). This will change the color of your entire object to black. You'll notice that the object is not lit in Vertex Paint mode, so when the entire object is black it can be difficult to see where your hills are. You'll have to move the camera around to see the shapes.

[Another newbie recommends: if you switch to the "object" buttons (f7) and turn on "Wire" under "Draw Extra" in the "Draw" panel/tab you should see a wireframe on top of the vertex colors you are painting, which makes it much easier to see where the hills are. Remember to switch this back off when you have finished painting.]

  • Now we're going to paint the places where we want rock to show through. Change the paint color to white. It's less likely that grass will grow on steep slopes, so start painting the tops and edges of the steeper hills white by holding down LMB and dragging your mouse (think MSPaint). If you didn't heed my earlier advice and still have a subsurf modifier in effect, the painting will be very choppy, so remove that now.
  • As you're painting, try to make some spots pure white by going over them again and again, but don't make any one area of white too large as this will make a huge area be all rock, and we're trying to blend two textures.
  • This process can just be trial and error getting the landscape painted the way you want. Once we apply our stencil later you may decide there's too much rock in one area, or not enough in another and go back and change it. A few things to keep in mind:
    • 20% opacity means that most of the original texture (grass, in our case) will show through, so the rock won't be very noticeable if at all. You'll have to go over the same spots a few times to increase the intensity.
    • You don't want a dramatic change from grass to rock, so be sure to blend white areas with black. That's why we're using the 20% opacity instead of just bumping it up to 100%.
    • Make your patches random and spotty. This will end up creating a more realistic effect once we combine the textures.
 
Painting the stencil onto the landscape
  • Once you're done you should have something that looks like this. Notice the mixture of white and black in some places, how it doesn't just go from pure white to pure black as you move down the hills. This will make a more natural blend and it will cause random rocky areas mixed in when the grass. Now we need to turn this into our stencil.
  • Go to the overhead view (NUM7) and make the projection orthographic if it's not already (NUM5).
  • Zoom in/out (Mouse Wheel or NUM+/NUM-) until the plane almost occupies the entire window.
  • Move the 3D cursor and any lamps or cameras away so that they're not over the landscape and take a screenshot.
 
The stencil after its been cut from your screenshot
  • Open your favorite image editor (I'm a traditionalist, so I still like MSPaint), and cut out the image of landscape. This is now your stencil. Save it under your favorite format.
  • Re-open the saved version of your landscape to undo the changes we made to create the stencil.


So why did we make our stencil this way? This allowed us to actually paint on our terrain so that we ensure we get the rock exactly where we want it. Using this method, you can customize your stencil to any object, as long as it has enough vertices. For example, if we just had a flat plane made of 4 vertices, this technique would not have worked because we could only paint the corners. That's why in the previous tutorial I recommended using a high (but not too high) number of vertices in your grid.

Applying the Stencil

edit

So now we need to apply the stencil to the landscape to mix our grass and rock textures together.

  • Return to either Object Mode or Edit Mode (TAB), it doesn't matter which.
  • Go to the Texture menu (F6) and add two new textures in the material (you should already have the grass texture).
  • Make texture 2 (the first new one you added) an image and load your stencil from file. Do not repeat this in the x or y directions. We want it to map to the entire object.
  • Make texture 3 an image and load your rock texture from file. This one you do want to repeat, just as you did the grass.
  • Now return to the Materials menu and select your stencil texture. It's a good idea to name your textures, materials, objectives, etc... so that they're easily identifiable.
  • With your stencil texture selected, switch to the tab labeled MapTo. Deselect Col (which maps the texture to the color), and select Stencil and No RGB. Stencil will treat this image as a stencil, and No RGB treats it as a black and white image. If you didn't select this second option your stencil wouldn't work.

 

  • In the preview tab you should notice your material change so that the grass and rock are now mixed. If you render, you'll see a much more realistic landscape than the one from the previous tutorial!

Noob Info: Be sure that for the rock - texture col is selectet because we want to color the landscape with the rock-texture! Otherwise it doesn´t work. Select Rock-Texture -> Map To -> col

 

Adding Snow

edit

Since you already have some nice mountains, why not add some snow to them? Adding snow is easy. All you have to do is add a fourth texture AFTER all the others. Make this texture the same as your stencil.

  • Make sure you're in Shading (F5) > Texture Buttons (F6) > Textures.
  • Click on an empty panel beside Texture Type
  • Click on the little box to the left of Add New
  • Choose your stencil from the menu (hint: it helps if you name your textures)
  • Render and see the results.

If you made your stencil properly, you should have some nice, snowcapped peaks. It's not much, but it's enough for a quick fix. If it isn't even, you probably didn't make your stencil properly (meaning pretty much all white on the peaks, and not much anywhere else). Of course, there are better ways to do this, ways I wouldn't know about; I discovered Blender merely three days before the time of writing. I leave it up to you to see the effect: I only have so much room and bandwidth for pictures!

This effect works by saturating the underlying color with white, depending on the amount of white in your stencil. A light gray will saturate it only a bit, whereas a bright, 100% white will cover it very clearly and efficiently. If you look closely, you'll see that the light gray on the stencil DOES make a difference, but it's not immediately visible and requires lots of fidgeting with the Render Preview and texture options. You might also try fiddling with the Stencil and NoRGB option, although it worked fine for me with both turned off (I use Blender 2.48a)

Some challenges:

  • Try to change the color of the snow. Hint: RGB
  • I've yet to do this, but try making snow out of a heightmap.

Multiple Stencils

edit

Remember in the first tutorial when I said to leave part of the landscape flat, because I'd be using it later? Well it's time to use it. I want to eventually use the landscape as the backdrop for a military base, so let's texture the ground around where the base will go to give it a dirt ground and road leading to it. *IMPORTANT* Just as before, the next few steps will be performing temporary modifications to your scene, so be sure to save your file before you continue so that the changes will not be saved!!

  • Switch to the Vertex Paint mode in the mode menu on the 3D View header.
  • Go to an overhead view (NUM7) and make the projection orthographic (NUM5)
  • Once again, paint the entire object black by selecting the color black in the Paint tab and clicking on Set VertCol.
  • For the next few steps, you may need to TAB back and forth from Vertex Paint mode to Object mode to make sure you're painting in the correct area. Make the opacity of the painter 1.0 and the size 10 so that we can work very precisely.
 
The stencil for our future base
  • Paint an area over the flat terrain in the shape of a generic military base, like you see here.
  • Reduce the opacity back down to 0.2 and increase the size to 20.
  • Paint the road leading away from the base. We've reduced the opacity and increased the size so that the road will blend more with the landscape around it instead of being more defined like our base.
  • Once you have your stencil looking the way you want, take a screen shot and save it. Then revert back to your previous environment (before you started painting on it).
  • Go to the Texture menu (F6) and add two new textures.
  • Load your stencil into the forth texture (the first new one), and the dirt image into the fifth texture. Once again, remember to set the x and y repeat for the dirt texture.
  • In the Materials menu (F5) select your new stencil and go to the MapTo tab. Deselect Col again, and select Stencil and No RGB. Notice the new preview.
  • Wait a second, where's the dirt path?!? Here's the problem and the reason I've included this section: stencils are cumulative. That is, the first stencil defines which portions of ALL successive textures will be drawn, including other stencils! In order for our new dirt path to show up, we need to make sure it's part of the first stencil.
 
Both stencils combined into one
  • Open your first stencil (the one you used to add rocks to the hills) in your image editor and combine the new stencil with it. The result should appear somewhat like this. Be sure that when you combine your dirt stencil with your rock stencil that the dirt stencil remains the same size and in the same place. That is, you want the two to be perfectly aligned.
  • Reload your first stencil on your material, the one we used for the rocks. Now the preview should look the way we want it to, and if you render you will see your new dirt area on the flat part of the landscape. You can add even more stencils the same way. Here is how all of the textures blend together:

 

NOTE I had to replace the grass texture in the above image since I could not find the licensing information for it. I apologize for the inconsistencies in the diagram that result from this.

Well there you have it! This is a pretty useful method of texturing complex objects. Check out our new landscape and how it compares to the previous, boring, single-textured landscape!

 

Once again, if you have any issues with the tutorial, or feedback (positive or negative), drop it in the discussions.

For 2.7 blender users:

edit
  • first you add the material
  • leave the grass texture at the default
  • add the next two textures , the stencil and the rock, soil etc texture as stated in the above tutorial.
  • go to the stencil texture
  • in the influence panel, uncheck col
  • check 'RGB to intensity' button
  • check stencil
  • others everything as their default values are good

-For me, with settings above, the rock texture was not very visible. It may help to play around with the color intensity settings in the influence panel (increase in the rock texture, and decrease in the grass texture) -