Please help me understand this terrain texturing method

Hello,

I just found this awesome terrain texturing method, I basically understand what’s going on, but I don’t know how to apply it.
I’m talking about this method:

You can downlaod the file on the author’s blog at: http://blog.mikepan.com/post/26950891126/procedural-terrain

Unfortunately, there are many things I don’t understand:

When I open the file, I can’t even texture paint, I get an error message on the texture paint tab saying:
“Missing Data”
“Missing Texture slot”

I really don’t know how to apply that node system and these textures that include 3 common textures at once.
The file includes two textures: Combined.tga and Mask.tga
Apparently the combined.tga includes the dirt, grass and rock texture which each one of them is stored in one color channel (R,G,B)
–> But if each texture is only stored as one color, how can it be reproduced as a fully colored texture (the dirt isn’t only red, grass not only green etc)? The author says that every single texture is saved as a grayscale texture, but how come that it is shown in the painted texture as a fully colored texture? Is it due to the color in the node?

  1. I don’t understand how these textures are generated. How can I create the combined and mask.tga textures?
    I have photoshop but I have no idea how to store a fully colored texture into one color channel. Furthermore, I have no clue how the mask.tga texture is generated at all… Is it generated automatically in blender while texture painting? I don’t understand how the gradient map is generated. The aim of this method is texture painting the landscape. Apparently the gradient map is used to determine how much of each texture is used. But isn’t that the goal of texture painting itself? To determine where each texture is displayed? So while I’m texture painting, will the gradient map be created automatically?

  2. If I wanted to include let’s say a 4th texture, eg. a sand texture, would that be possible? or is this method limited to 3 textures because of the RGB storing?
    And how could I include a normal map? Would I have to ditch one of the mask.tga textures (eg. normal map instead of ambient occlusion)? Is it even possible with this method to use a normalmap?

  3. In the node editor there’s a node called “Detail map”.
    I never heard of a detail map before. What is it used for and why is he using the combined.tga texture for that?

Sorry for all these questions but this is a topic in which I don’t have enough knowledge to help myself out.

Thanks a lot for your responses!

This uses an insane amount of texture re-use and layering. I’d suggest trying to implement your own, simpler texture multiplexing before you try to understand that (admittedly relatively messy) blendfile.

  1. The blend is quite old, so it doesn’t surprise me. Try saving, reopening, unpacking, repacking images etc.
  2. It is reproduced as colour because all the textures have one fundamental colour. Grass is green, dirt is brown, rock is white. So you can take the texture and multiply it by that colour.
  3. I generate textures like this in gimp, using the ‘decompose’ tool to extract channels from one image, multiply it by a channel (R, G or B), and then use ‘add’ to add them together into a final image. I’ll have to make a tutorial on this sometime.
  4. You need to introduce a new image, or with four, you could actually squish it into the alpha channel because som formats save the colour of transparent areas. But yes, this technique is generally limited to 3.
  5. That’s just a frame he drew around it to try make it clearer what those three nodes were doing. (Add->Layout->Frame). All the detail map bit does is add some really fine details. If you aren’t sure what some part is doing, connect it up to the output, so you can see what it’s doing.

This blend is the one that introduced me to the technique, and I love it. I’ll have to make a proper tutorial at some point.

There is one sneaky trick he uses in the blend, and that is the property of multiplying colours to extract said colour. So if you multiply blue by blue, you get blue, but if you multiply blue by red, you get black. So when he takes the re-hued red channel of the mask and multiplies it by the combined texture, it extracts all the channels into all the right places in one go.

Thanks a lot sdfgeoff, that clarifies a lot.
I will look for tutorials in photoshop, there must be a similar “decompose” tool.

I still have a doubt about how the gradient map is created, which is responsible for assigning each texture (the R-Channel from the mask.tga).
I know how to bake an ambient occlusion and a light map. I would create the specular map and the normal map out of the diffuse map.
But how do I create the gradient map?

And could you explain to me, how I could include one further RGB-image to include 6 instead of 3 textures?

I will look for tutorials in photoshop, there must be a similar “decompose” tool.

Use it to extract the Value (HSV). If you’re lazy, just use the desaturate (greyscale) tool as this does pretty much the same thing.
I’ll make a tutorial on this (in gimp) tomorrow.
Also, GIMP is free, so I’d say just use that.

Gradient Map

So the maps called ‘mask.tga’ consists of three channels:

R - which terrain type
G - AO/shadows/baked lighting
B - Specularity/shinyness

The thing you seem to call ‘gradient map’ in the red channel is treated differently to the others. It gets turned into some more colors, which seems a bit odd at first glance. Don’t think of them as colours, think of them as locations for textures. So where the red channel (of mask.tga) is zero, the intermediate color is red, which means that location will be dirt. If the red channel is 0.5, then the intermediate color is green and the part of the map defined by that location will be the grass.
Think of it like saying: If the channel is between 0 and 0.1, make it be grass. If it is between 0.1 and 0.2 make it be dirt etc.
This means you can use a single channel to map all the textures to different parts of the map. This can be expanded to defining however many texture channels you like within a single channel of an image (with a few other changes) so long as you are happy with the texture transitions. So in this example blend, if you try to go from stone to dirt, you will get a thin band of grass. If you get more textures, you get more transitions. So if I have six, then to go from one side to the other I may have to go through a maximum of three others. There are some tricks we can use to get around this, though I have not seen them implemented anywhere.

And could you explain to me, how I could include one further RGB-image to include 6 instead of 3 textures?

This will increase the complexity of the setup by a significant fraction. I’ll have a think about if you can stuff it into a single image, because picking between the two images will not make things simpler.