12 Lesson 9: Layer Effects, including more text tricks

By now, you should be getting comfortable using a few layers, maybe
even more than a few, to draw or paste parts of one image on top of
another. But gimp offers other interesting ways to combine layers.


A Layer Mask is a way of making a layer transparent in some places
and opaque in others. It's sort of like the opacity slider in the
Layers dialog, but it's more powerful.

A layer mask is a black-and-white image which is aligned with the
layer it masks. Here's how it works: everywhere the layer mask is
white, that layer is opaque. Where the mask is black, the layer is
transparent. Where the mask is grey, the image is translucent: the
darker grey the mask is, the more transparent the layer is. You can
draw on a layer mask with any gimp drawing tool. The catch is, you
can't really see what you're drawing: you can only see its effect on
the layer, and the tiny copy of the mask in the Layers dialog.

Confused? Let's do an example to make it clearer.

Let's say I have a photo of my car:
and I put a label on it, using the text tool:
That text is kind of intrusive, though. What if I made it sort of
fade into the background as it gets closer to the car?

The first step is to create a layer mask: I go to the Layers dialog,
right-click on the text layer, and select "Add Layer Mask..."
A dialog comes up, but the defaults, of "White (full opacity)"
is almost always the right thing to choose. This means that the layer
mask will be white everywhere, so the layer will initially be visible

In the Layers dialog, now a new box appears to the right of the box
for the text layer, showing a miniature preview of what the layer mask
looks like (a white rectangle). The box is also surrounded with a
white border, which means that the layer mask is selected: if
you draw on the image right now, you'll be drawing into the layer
mask, not into the layer.

If you ever want to see what a layer mask looks like in full size, in
gimp 2, go to the Layers dialog, right-click on the layer and choose
Show Layer Mask. I don't know of any way to do this in gimp 1.
Try it now (notice that the white border on the mask box in the
Layers dialog turns a different color), then choose the same menu
item again to go back to viewing the text layer normally.

Now it's time to draw on the layer mask. I'll use the gradient tool,
to make a fade that goes from white (fully visible) at the top of the
layer to black (transparent) on the bottom).

I select the gradient tool in the toolbox: it looks like a horizontal
fade from black to white (maybe with another color in between,
depending on gimp version). There are tons of tool options: for
now, I want all the defaults: Mode Normal, Shape Linear.

The normal way to use the gradient tool is to mouse down at one end
of the layer, then drag to the other end. I want to fade from the
foreground color (black) at the bottom to the background color (white)
at the top, so I'm going to click at the bottom of the text layer,
then drag straight up. When I let go, the layer mask is filled with a
gradient, where the gradient is darker, toward the bottom of the text,
the text will be more transparent. Like this:

If I "View Layer Mask", this is what I see:
while my layers dialog shows a small preview of the mask:

It's sometimes confusing to have a layer mask selected. When you're
done drawing on your layer mask, try to remember to click on the layer
preview next to the layer mask, so that the mask isn't selected any
more. Otherwise, gimp will give you weird complaints when you try to
save as jpg, and you'll get confused (at least, I do) when you try to
do anything with that layer. If you ever try to draw on a layer and
nothing appears, one thing to check is whether you have a layer mask
selected, instead of the layer itself.

You can use a layer mask for more than just gradients. Since it's
actually an image, and you can draw on it just like an image, you
can use all the normal drawing tools: you can draw on the mask with
the pencil tool to make only parts of the image transparent, or
you can use the ellipse select tool and bucket fill to make an
oval area disappear. You can even use a layer mask instead of
the selection tools we used in lesson 7: if you draw white on the
layer mask everywhere outside your chosen object, then you end up
with a transparent layer with just the object in it, and you can
put other backgrounds underneath. Newsforge had an article
mentioning that technique just recently:


Bump Map is a built-in gimp filter which uses one layer to generate
a 3-dimensional lighting effect on another layer. It comes in handy
for all sorts of projects, but especially for making text.

I'll start by making a new image, and using the Bucket Fill tool to
fill it with a pattern. Then I'll put a layer of white text on top of
it: http://shallowsky.com/images/gimpcourse/lesson9/bumpmaptxt.jpg

Now I'm going to use the white text as a bump map for the woodgrain
pattern. I select the woodgrain background layer in the Layers
dialog, then go to Filters->Map->Bump Map...

The Bump Map dialog comes up (in Gimp 2.2, it includes a preview).
The dropdown at the top lets you choose which layer will create the
shape of the bump. It can even be a layer in a different image, as
long as that image is already loaded in your current gimp session.

You can adjust lots of different parameters, such as where the light
source appears to be coming from (that's Azimuth), how high the bump
will be, and how wide it will seem to be.

Play around with the parameters, and try it. The background layer
will change to include the "bump" generated from the text layer.
The text layer is still visible: you may want to toggle it off
so that you only see the bump map.

Here's an example:
it: http://shallowsky.com/images/gimpcourse/lesson9/bumpmap.jpg

If you want a smoother bump, use gaussian blur to blur the edges of
the text layer before running the bump map. Like so:

You can run bump map on colors other than white, but usually it works
best on white. Experiment with it to get just the effect you want.


You may have noticed the Mode dropdown in the Layers dialog,
and wondered what that was.

Layer Modes control how a layer is combined with the ones below it
to produce the total image you see. Normally (in "Normal" mode),
you see all of the layer on top; if there's anything still
transparent, then you see pieces of the next layer down; if there's
still anything transparent, you see the the next layer, and so on.

But gimp can combine layers in ways more complicated than that.
For instance, for each point in the image, it might show you the
top layer minus the second layer, divided by the third layer.

Why would you ever want to do that? It turns out there are some
interesting effects you can do by combining layers in odd ways.

Let's say I start with a white background layer; then, starting with a
new transparent layer, I use the pencil tool to write some blue text:
Then I make a drop shadow, then blur the original layer:

By playing with layer modes, I can change this in interesting ways.
For example, with the blue layer selected, if I change the mode to
Divide, the color changes and I get this odd effect, somewhat 3-d effect:
Screen mode gives me a different 3-d effect:

Now for some even weirder effects: I'll turn the Background a medium
grey (using Levels or Bucket Fill), then try some different modes on
the blue blurred text layer:

If you wanted to use the result of one of these, you could use "Select
by Color" to select out the grey background, and Edit->Clear it to
leave you with just the text. Here's the Addition one:

Don't worry if you don't understand exactly what each mode does. Most
people don't. The important thing is to know that Modes exist, and
that you can use them to combine layers in interesting ways. This
means that (a) you can play around with trying different layer modes
to see what they do, and (b) you can follow tutorials on using layer
modes, such as these two:

Here's a discussion of what some of the layer modes do mathematically,
for those so inclined: http://www.pegtop.net/delphi/blendmodes/
It's oriented toward Photoshop, not Gimp, but as a Gimp user you can
very often follow Photoshop tutorials -- the two apps have many of
the same capabilities.

Homework: Use any combination of Layer Masks, Bump Map, and Layer
Modes to create something interesting from an image composed of
several layers. Doesn't have to be text: you might be surprised
what you can do starting with just a mouse scribble.

Next Lesson: Stitching Panoramas from Multiple Images.