# Mapping Resources > Tutorials/How-To >  [Award Winner] Using the mosaic filter to make towns in Gimp

## torstan

Now this has certainly been done before but I've been playing around and trying to get a good town result in Gimp using the mosaic filter and I think I've ended up with something rather nice. Here's the end result:



and a variation with a few tricks applied:



I'll go through the steps I took to get this in the following tutorial.

----------


## Ascension

This looks pretty promising.  PS has a similar filter and with a lil tweaking you should be able to do this pretty darn easy.  I'd like to see the process as I've never actually tried it, only thought about it.  Nice job.

----------


## torstan

Thanks - obviously that is a somewhat extreme example, and it may well be that it is best used for smaller regions as that looks a little overwhelming, but the sense of buildings seems to work there. Anyway, on with the tutorial.

*1. Lay out your roads*
Create a new transparent layer (shift-click the new layer button on the layers dialogue). Call the layer Roads.

First things first. Lay out the areas that will form your roads. Do this with a nice large brush (your actual roads will be a little smaller than these). Your image should look something like this:



*2. Get some colours for your roofs*
Now we want some nice variation in the colours of the roofs of the buildings. No town looks any good with uniform roof colours. What we will do here is create a solid colour layer that will be used by the mosaic layer as the base for the buildings further down the line. So if you want one district to have blue roofs - make sure that area is blue here.

I want to have roofs with a wide variety of browns in the roof colours. To this end I create a new layer and call it colours. I then take the brush tool and *make sure that the opacity sensitivity for my tablet is off*. I want the whole layer to be opaque so that the roofs that are generated are opaque. Now I pick the *Use colour from gradient* option and pick the Browns gradient from the drop down. I then colour in the whole map with random colours. If you want colour variations that are less random - this is the place to make sure they are in the right place. You should now have something like this:



[b]3. Using the mosaic filter[b]
Now we are ready for the crux of the process, using the mosaic filter. Make sure you have your Colours layer selected and go to Filters->Distorts->Mosaic. Now what you put in here will affect the shape and size of your buildings. Play around with either Octagons and squares, and squares and adjust the neatness slider and see what the results look like. Of course, adjust the size slider too to fit the size you want your final buildings to be. The other settings I would set to the values shown here because they give flat coloured tiles with white gaps between which we will need later.

Here are the settings I use:


This will now give you a layer that we'll use later as the base of the colour for our buildings.

*4. Creating a mask*
First of all duplicate the layer Colours and rename it (I've called it streets in my example, but building mask would probably be more appropriate). Now go to Colours->Desaturate. The various options don't really matter here. Next go to Colours->Threshold. Now you'll see that our lovely mosaic pattern has suddenly gone very black and white. Play around with the location of the threshold value until you are happy with the density of the buildings. I left it so there were a couple of holes in the pattern, but not too many.



Now we need to cut out the roads from this as we do not want buildings on our roads - or even half on the roads. So first move the roads layer above the rest and select the magic wand tool with 'select merged' checked, like this:



Okay, I'll carry on from here tomorrow.

----------


## torstan

Now, set the threshold to 0 - this is important as otherwise you'll end up with some slightly transparent buildings. Click the magic wand on the road and you'll get a selection that encompasses the road and all the houses that are adjacent to it.

Now make sure the black and white mosaic layer is selected and go to Edit->Fill with Background colour to fill the selection with white (or ctrl-. for quick).

*Do not* get rid of the selection, we want to put some of those buildings back in again.

You should now have something like this:



To replace some of those houses we need a little bit of trickery. Take the following steps:
1. Make sure the Roads layer is selected.
2. Go back to the magic wand and *deselect* the Sample Merged option.
3. Change the selection preferences to Subtract from Selection.

Your tools window should now look like this:



Now click on the black road. Now you just have the white space selected where you want to replace buildings. However this still borders the road, so if we just fill that with black then we'll be back where we started. To get around this do the following.
1. Go to Select->Shrink... and shrink your selection by 2 pixels, leave all other options at their default.
2. Go to Select->Grow... and grow by one pixel.

This has the effect of getting rid of tiny areas and retaining larger ones.

3. Make sure your black and white mosaic layer is selected.
4. Go to Edit->Fill with Foreground colour (or ctrl-, for quick).

You should now have something that looks like this:



Essentially we are now done, having created a mask that has all of our houses in it. Now the challenge is to make this pretty. I'll address this in the next post.

----------


## torstan

Now we'll go back to that colour layer we left alone. First of all, we want to get rid of all the blocks of colour that represent houses that we no longer need.
1. Make sure your black and white mosaic layer is selected.
2. Select all (ctrl-a).
3. Copy (ctrl-c)
4. Select your colour layer.
5. Right click the colour layer in the layers dialogue and select Add Layer Mask...
6. Click okay in the dialogue
7. Select the *layer mask* in the layers dialogue.
8. Paste (ctrl-v) and anchor the pasted layer to the layer mask (click the little anchor at the bottom of layers dialogue).

Now the layer mask is the wrong way round at the moment - it is masking out the buildings and only revealing the white between. With the layer mask selected, go to Colours->Invert. You'll now have the mask the right way round. If you move the colours layer to the top of your layer stack you should now see something like this:



This is all very well, but the houses are just flat blocks of colour at the moment. We want to give them some substance. To do this, take the following steps.
1. Duplicate the black and white mosaic building mask layer and rename it something like "Building Bump Map"
2. Go to Colours->Invert to make the streets black and the buildings white. Remember, bump mapping takes white points to be the highest and black points to be the lowest, so we want the streets to be the lowest point.
3. Change to the Select by Colour Tool with threshold set to zero, and click on one of the white buildings to select all the buildings.

You should now have something that looks like this (note that I've turned off the visibility of the other layers so that I can see what I'm doing):



4. Switch to the gradient tool.
5. Select the Shaped Angular option in the Shape drop down.
6. Check the switch direction checkbox beside the Gradient: drop down
7. Click and drag inside one of your selected buildings to fill all of them with a shaped gradient.
8. Edit->Select None (ctrl-shift-a) to see your handiwork.

It should now look something like this:



This is now ready for use as a bump map.

9. Turn off the visibility of this layer and select your Colours layer again.
10. Right click the layer in the layers dialogue->Apply Layer Mask
11. Go to Filters->Map->Bump Map...
12. In the Bump Map dialogue make sure that your Building Bump Map layer is selected as the bump map.
13. Play with the Depth slider until the preview looks good.

Here are the settings I used:



14. Now click okay and you should have something like this:



In the next section we'll look at putting in a background and some finishing touches.

----------


## torstan

Now we'll put in some colour to finish the whole thing off. First of all, let's put in some grass background.

1. Create a new layer
2. Place it under your Colours layer and your Roads layer
3. Fill it with a nice grass texture (select a grass texture and then hit ctrl- :Wink: .

Now it will look something like this - its starting to come together:



We also want roads that aren't black lines. For this take the following steps:
1. Create a new layer and call it Street Colour
2. Fill it with a nice street texture - I've found that the default Gimp pattern Slate is actually not too bad as a starting point.

Now this makes everything grey - we don't want that. We want to create a layer mask that will show only the areas we want.
3. Right click Street Colour in the layers dialogue and go to Add Layer Mask...
4. Select Black - full transparency in the Layer Mask Dialogue.
5. Select your Roads layer.
6. Select the Magic Wand tool and *make sure the selection mode is Replace Current Selection*
7. Click on the road to select all your roads (if you have disconnected road sections it is better to use the Select by Colour Tool here instead).

You should now have something that looks like this:



8. Select the layer mask for the Street Colour layer in the layers dialogue
9. Go to Select->Shrink and pick 2 pixels
10. Fill the selection with white.
11. Edit->Select none (ctrl-shift-a).

Now this gives a very hard edged road network. I personally think this is a little too clean. To fix this, still with the layer mask selected, do the following:
12. Go to Filters->Blur->Gaussian blur
13. Accept the defaults and hit okay.

You should now have something that looks like this:



Now the roads are a bit dark, so I used the Colours->Brightness/Contrast dialogue to up the brightness of the roads a bit:

----------


## torstan

Okay, so now we want to add some shadows.

1. Go back to your black and white buildings layer
2. Use the Select By Colour Tool to get a selection of all the buildings
3. Go to Filters->Light and Shadow->Drop Shadow
4. Pick the following options in the dialogue:



5. Hit okay and move the layer under your Colours Layer

That's it done. The town is finished and the houses are all there. My final screen looks like this:



and the final map looks like this



Now there are lots of things that can be done to tweak this process - if you fiddle with the settings in the mosaic filter specifically you will be able to get more or less spaced out houses and different shapes. Equally you can posterise the colours layer and apply a stroke to the houses to make it look more hand drawn. Here I also put all the colour layers over a parchment background and changed them to multiply, overlay, or hard light, to get a less intense feel. I added an overlay layer with some broad regions of light and dark for the hills. I also used the bump map layer as an overlay layer to give a bit more light and shade to the buildings.



Here's the layer layout for that map:

----------


## bryguy

love the tutorial! and I think that the random village shapes look cool  :Smile: 




btw, what did  you do for that last pic? it looks awesome  :Very Happy:

----------


## torstan

I'm glad you liked it. I'd urge all that read through it to rate it, if you like it or not.

The steps I took to make it look pretty are:
1. Add a parchment texture as the background.
2. Change the layers above in the following way:
 a. Duplicate the layer
 b. Set the blend mode of the bottom of the two copies to overlay
 c. Reduce the opacity of the top layer to between 50-80% depending on the result

This softens the colours and blends the colour scheme together a little more. Now to create some light and dark regions:

3. Create a new layer over the map and set the mode to overlay.
4. Fill with precisely 50% grey (you will see no effect at this stage as 50% grey does nothing for overlay layers. Don't worry, it will be important later).
5. Go to the dodge/burn tool and take a nice large fuzzy brush. Make sure you have the tool set to burn and the range set to shadow:

6. Now run the brush over those regions that you would like to be dark - essentially hill-sides away from your sun.
7. Now switch to dodge, and set the range to midtones.
8. Run the brush over those regions that are in the light - hill tops and the sides of hills facing the sun.

You will now have soft highlights and shadows on your map. This will give the impression of hills. Repeat these steps to get deeper shadows and feel free to use the smudge tool with a large fuzzy brush to smooth out any shadows that are too dark.

If you set your overlay layer to normal you'll see that you've really got a grey layer with lighter and darker regions on it. For the map above, my overlay layer looks like this:


That's all there is to it.

I've also uploaded the .xcf file in a zip for people who want to see the breakdown of all the layers and blending modes for that final image. I hope its useful!

village2.zip

----------


## Sagenlicht

Nice tutorial torstan  :Smile: 

Repped and rated  :Smile:

----------


## torstan

Thanks for the bump and the 5 stars  :Smile:  That's quite a thread ressurection you achieved there.

----------


## Sagenlicht

Heh - I had close to no time in december, so I try to catch up a bit  :Smile:

----------


## Sagenlicht

Torstan, I tried your tutorial, but I got a dumb question:

I get some artifacts where buildings used to be (see attachement). Do you know what I am doing wrong? Is it the threshold or the way I do the selection?

I do NOT follow your tutorial 1 by 1, I create the color layer by filling it with a color then add a new layer with plasma, desaturate it, set it to overlay and merge it down, giving some color variations for my town. This is creating a for more uniform color variation than yours and I am aware that it aint that good, but for testing its faster.

----------


## Sagenlicht

Hmm torstan,

I did some GIMP scripting on your tutorial.

Attached is a GIMP script that tries automate your tutorial. Maybe you could try it and tell me how do you like it and what could be improved?

Ofc, everyone else can download it as well but keep in mind that it aint perfect yet  :Smile:

----------


## Jkaen

Just caught up with this tutorial and it looks great, I am at work so can't play with the script, but if you can get this scripted you will make me very happy!

----------


## Vandy

Hi, All.

Here is torstan's excellent tutorial as a PDF document.

Regards,

Gary

----------


## ravells

You're carving out a seriously cool little niche as the Guild's pdf scribe! Thanks for all your hard work, Vandy! It is much appreciated. Have some rep!

----------


## Black Tower of Time

Thank's, nice work with the PDF version especial that you added a Table of Content too.

----------


## Jalyha

I did it I did it I did it!!!!!!  :Very Happy:   :Very Happy:   :Very Happy:  

Thanks so much for the tutorial it's the first one I could follow right all through to the end, and I DID IT!


I mean, I didn't do it very well, and I used my manor from the contest to fill my castle space but I made a whole city!  :Smile: 


I'm a tiny bit excited  :Razz: 

Here's what I made:



It's not very good, but if I can follow the tutorial, I can practice, right ?  :Smile: 

Thank you sooooooo much

xoxoxo

----------

