In my game I'm trying to use texture splatting technique which allow me to have up to 5 textures on landscape chunk. For this I need to generate blend map so my game engine know how to blend those textures. I was googling a lot and found few tutorials describing how to mix 2 textures with one stencil. But I need to mix 4 textures and since I'm very new in Blender and design I'm experiencing few problems:

  1. For beginning I added 3 textures (grass, dirt and sand) and 2 stencils between them. But with this approach I can only draw sand on dirt, I cant add sand on grass because first stencil block it. It does change stencil but I can't see sand over grass.

enter image description here

how can I solve this?

  1. At least I can paint on stencils and now I have to combine them to get one colored texture with each channel intensity of some texture. I was manage to achieve this using node editor:

enter image description here

but now, how do I export this to external image file so that I can use this blend map in my game?

Maybe in common I moving in wrong direction and there are better ways to generate blend map for 4 textures, while painting on landscape mesh in Blender?


2 Answers 2


You basically had the right idea about breaking it down by color channel.

Here's one example of how you can solve this:

Using RGB and black to create a 4-texture blend map

A blend map controlling the mapping of four grass textures

I could have used the alpha channel, but opted for the absence of color (black) instead to represent the fourth channel because you can't see the alpha channel in the 3D Viewport or paint it in Texture Paint Mode.

This is what the node setup looks like (Blender Internal):

Blender internal material node setup

What's happening in the node setup

From the 'Blend Map' texture the RGB channels are separated and each one used to additively factor in the color of the texture against solid black.

Separate RGB sparates the red, green, and blue channels The grass texture is added, only in areas where the blend map is red

The RGB Curves node just gives enough of a boost that the transitions between regions won't look dark. (Mute the node in the .blend to see the difference it makes.)

The ColorRamp and Invert nodes isolate the darker parts of the blend map and that becomes the fourth channel mask (black).

Isolating darker areas of the blend map using the ColorRamp and Invert nodes

The Material node receives the final additive mix of color data (the four textures) and applies it to a material created just for this node setup that I named 'NodeComponent'. This is just the quirky way of doing things in BI's nodes so that the material will receive specular highlights and not be shadeless.

A Material node is inserted before the Output node in order to receive light and shadows A separate material exists for the purpose of giving specular, etc

For cases when you need more than four textures, you can repeat the blend mapping process iteratively. So for example, within the red region of the blend map there could be another blend map with its own red, green, blue, and black regions. So you could use the first blend map to control what kind of terrain (grass, sand, snow, stones), and then the second level blend map to map out the grass textures within the grass region. In such a case it would be best to create a Group node and reuse it for each blend map, to keep your nodes manageable.

Getting it into your game

As for exporting, you can bake your blend map to a new massive texture, but it wouldn't be good for a game because such a large image would need to be generated. It's better to use the individual tiling textures and the blend map to combine them. I don't know what game engine you plan to use, but if you are using the BGE or Blend4Web you can use this node setup as-is. For other engines you should look into what kind of data those engines expect for a blend map.

*Terrain material is set to 'Shadeless'. Turn off 'Shadeless' to see lighting.

  • $\begingroup$ Thank you for this extended response. With your approach I should draw colors on terrain instead actual drawing textures. So I would not see how it all would look on terrain unless I load it into my game. With my approach I can see where is there should be more/less of each texture so it make drawing process more descriptive. But I have that overlapping problem (#1 described in my question). $\endgroup$
    – SET
    Commented Apr 23, 2016 at 6:30
  • $\begingroup$ @SET You can press [Shift Z] to quickly toggle Viewport Rendering. Make sure BI's material nodes are enabled when previewing the terrain, and disabled when painting (because BI node materials and Texture Paint Mode are not compatible, so you'll see only magenta if you try to paint on a node material). Add a texture slot for the blend map texture (while nodes are disabled) and move this to the top of the texture stack so that it will show while in Texture Paint Mode. If you do this it's actually a very efficient workflow for painting your blend map and checking the results. $\endgroup$
    – Mentalist
    Commented Apr 24, 2016 at 5:44
  • 1
    $\begingroup$ I think this could be adapted to create a very nice PBR painting setup by using this to mix actual shader trees in a greater tree for an object. $\endgroup$ Commented Feb 28 at 21:56
  • 1
    $\begingroup$ @CraigDJones You're absolutely right! Also, more than 4 colors can be used by targeting specific colors using a color selection method instead of using RGB channel values. There eventually is a practical limit, but it should work for RGB+CMYK+A giving 8 channels, although Alpha (if you really need 8) would be targeted separately. Of course you can keep going, targeting more and more specific colors, but it gets harder to understand and more complicated as you try to prevent unintentional targeting where colors mix. Consider texture memory too. $\endgroup$
    – Mentalist
    Commented Mar 6 at 10:10
  • 1
    $\begingroup$ I am working on a revised version of this 4 color set up for Cycles/Eevee but with some additional controls added for manipulating the Metalness/Roughness of each area as if they are shaders but mixing all before the single Principled Shader. It is just taking a long time and testing to make sure I don't break something. $\endgroup$ Commented Mar 15 at 16:28

I came back to this question in hopes to relearn something about stenciling and shaders and discovered that this was actually from Blender Internal Renderer days. I set out to figure out how to achieve the same thing in Cycles, and initially didn't worry about anything other than the mixing of the diffuse colors. Then once I got that sorted out, I attempted a few other stages of mixing to get this big 4 Color Stencil Mixer node group that allows to affect the Color, Metallic, Roughness, Bump, Specular and Displacement properties on one Principled BSDF instead of what I had attempted earlier of mixing 4 separate Principled BSDF.

In the screen shot, you will see 13 image nodes, 12 are folded down. One that is open there is the 4 color map for splatting, the other twelve are the 4 individual color maps, their corresponding spec maps and their displace maps that I generated with NormalMap Generator. I haven't yet achieved a mix technique for Normal maps, that is in research for now.

I used some basic generic free image textures from online to use as splatter inputs for now, but I want to pursue the idea of what this could mean for hand painted textures turned into interesting materials.

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .