Several repeating textures painted on a surface

I created a terrain in Blender and want to paint it with gras, dirt etc. textures in the same way it is done in game editors (e.g. Unity).

I’m using Blender 2.58.0 and want to export to Unity.

I tried several things but nothing really worked in a good way.
Just using the texture as brush (fixed) messes up the repeating factor of the textur if you make more than one stroke.
The only working way I found was using stencils and two textures, but adding a third one didn’t worked so well.

I guess I need to work with alpha maps or something, but I didn’t figured out to use them correctly.

I hope someone can help me, thank you.

there was a post similar to this one recently, it might be hard to find though. the solution involved the first tutorial in my signature, and then repeating the process after baking the texture, if I recall correctly.

Thank you for your reply.

I checked the the threads of the last 2 months (or even more) before posting this and haven’t found something. It’s very likely that I missed it.

I had a similiar approach to what’s in your tutorial with using stencil maps.
But the problem pops up the moment you want to have more than two textures.

Let’s say I use three textures; gras, dirt and sand.
I could use the gras as underlay texture which fills up the whole area.
Then I would add a stencil map which overlays it with the dirt texture.
Now when I want to have dirt I modify this stencil map and paint white areas on it, or when I want to have gras again I paint those areas black.
Now I add the sand texture which overlays the gras and the dirt.
When I want to have dirt somewhere but there is already sand, then I need to open the stencil map for sand and remove those areas, and after that I would need to open the dirt stencil map and paint the areas where I want to have the dirt.
This method would take way too long and is a hassle to work with, especially on making the final touch.

Then an idea struk me and I thought it would be a solution, but I was wrong.
I thought about making a node network and substract one stencil map from the others and vice versa. So this way it would work like it does in some editors. When I paint on the dirt stencil map and hit an area with sand on it, it would automatically substract it from the sand stencil map.
But here comes the part why it wouldn’t work. On the material node screen I would get it to work, but I have no way on outputting it as a texture (stencil map).
So obviously I need to do it on the texture node screen which would work fine, but Blender doesn’t allow to have the texture you are node networking in the be used as input (a red texture with white line appears instead).

And this is the point where I’m stuck now.
But I never worked with nodes before, so hopefully someone knows a nice trick to it to make it work.

The checkerboard texture is just the default. You should be able to change that to any existing texture. I am a bit sketchy on texture nodes still, so I might be missing something here.

I made a simple example of what I meant.
I didn’t painted the texture like it is on the screen, Blender automatically changes it that way.


here I added two texture channels to the default cube, then activated nodes, added an input of type ‘texture’, and when I click on the field with the little checkerboard, I can see those two channels among my options.


if you select the texture in which node you are (Texture.001 in your screen) and connect it in some way to the Output, it changes to the red with white line